How to get rid of “Terminal will be reused by tasks, press any key to close it.” behaviour?

后端 未结 4 2109
渐次进展
渐次进展 2020-12-31 00:11

Upon executing a task (cargo build in this case), the following appears in the VSCode terminal:

> Executing task: cargo build <

(output of the task he         


        
相关标签:
4条回答
  • 2020-12-31 00:53

    An alternative solution is to set the output window to auto-focus.

    Add this to the task definition:

        "presentation": {
            "focus": true
        }
    

    Then it's not that annoying anymore because you can dismiss the compiler output with a single key press.

    The benefit of this is that the task output is visible, so you can see if there were any errors or warnings.

    0 讨论(0)
  • 2020-12-31 00:56

    To be clear, executing a task will always create a new integrated terminal in VS Code. There is no way around that. The most important thing is for the original terminal to be displayed instead of the newly created integrated terminal. (We want the original terminal revealed.)

    @Gregory Cosmo Haun's solution will suppress the message "Terminal will be reused by tasks, press any key to close it". However, it still reveals the new integrated terminal instead of the normal terminal. (so you still have to press "any key" to close that terminal and reveal the original terminal)

    A better solution would be to set "reveal": "silent", which will still create a new integrated terminal, but not reveal it unless there is an error while executing your task. I also set "clear": true (which is optional) so that the terminal is cleared before executing the task. I deliberately omit "showReuseMessage": false (which is optional) but you can add it. Who cares if the prompt is suppressed or not? The most important thing is that the newly created terminal is not revealed so I don't have to "press any key" to close it.

    "presentation": {
      "reveal": "silent",
      "clear": true
    }
    

    BTW, you can also set "reveal": "never", but you would normally want to see the error message if there is a problem with executing your task.

    In my opinion, this is the best possible solution. Yes, a new integrated terminal will always be created when executing a task, but at least it won't be revealed (unless there is an error) and you can safely ignore it without having to press any key to close it.

    0 讨论(0)
  • 2020-12-31 00:59

    One possibility is to add the following command to the "tasks":

    "presentation": {
                "panel": "new"
            },
    

    as

    "tasks": [
        {
            "label": "python",
            "type": "shell",
            "command": "python",
            "presentation": {
                "panel": "new"
            }
        }
    ]
    

    This does not fully solve the problem but at least does not pile all the results one after the other in the panel.

    Inspired by https://github.com/Microsoft/vscode/issues/35642

    0 讨论(0)
  • 2020-12-31 01:01

    There is a new presentation option called showReuseMessage. Add the following to your task definition.

    "presentation": {
         "showReuseMessage": false
    }
    
    0 讨论(0)
提交回复
热议问题