如何摆脱“终端将被任务重用,按任意键将其关闭".行为? [英] How to get rid of "Terminal will be reused by tasks, press any key to close it." behaviour?

查看:7316
本文介绍了如何摆脱“终端将被任务重用,按任意键将其关闭".行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行任务(在这种情况下为货运)时,在VSCode终端中将显示以下内容:

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

> Executing task: cargo build <

(output of the task here)

Terminal will be reused by tasks, press any key to close it.

令人讨厌的是,这将我带出了普通终端,然后我必须获取终端窗口的焦点并按一个键才能返回.而当我这样做时,货运量的输出就消失了.

Annoyingly, this takes me out of the normal terminal and then I have to acquire focus of the terminal window and press a key to get back. And when I do so, the output of cargo build disappears.

如何停止这种行为?

如何摆脱文本的第一行和最后一行?

How do I get rid of the first and last lines of text?

推荐答案

要清楚,执行任务将始终使用VS Code创建一个新的集成终端.没有办法解决.最重要的是要显示原始终端,而不是新创建的集成终端. (我们希望显示原始终端.)

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的解决方案将禁止显示消息终端将被任务重用,请按任意键将其关闭".但是,它仍然显示了新的集成终端,而不是普通终端. (因此您仍然必须按任意键"以关闭该终端并显示原始终端)

@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)

一个更好的解决方案是设置"reveal": "silent",它仍然会创建一个新的集成终端,但是除非执行任务时出错,否则不会显示它.我还设置了"clear": true(可选),以便在执行任务之前清除终端.我故意省略了"showReuseMessage": false(这是可选的),但是您可以添加它.谁在乎提示是否被抑制?最重要的是,不会显示新创建的终端,因此我不必按任何键"将其关闭.

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
}

顺便说一句,您也可以设置"reveal": "never",但是如果执行任务有问题,通常您会希望看到错误消息.

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.

这篇关于如何摆脱“终端将被任务重用,按任意键将其关闭".行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆