gpt4 book ai didi

c - vscode调试后如何自动关闭任务终端

转载 作者:行者123 更新时间:2023-12-05 02:56:37 47 4
gpt4 key购买 nike

启动.json

...
"preLaunchTask": "startDebug",
"postDebugTask": "closeOpenOCDTerminal"

任务.json

{
"version": "2.0.0",
"tasks": [
{
"label": "startDebug",
"type": "shell",
"command": "make -j4; openocd -f interface/cmsis-dap.cfg -c 'transport select swd' -f target/stm32f1x.cfg",
"isBackground": true,
"problemMatcher": {
"pattern": {
"regexp": "."
},
"background": {
"activeOnStart": true,
"beginsPattern": ".",
"endsPattern": "."
}
}
},
{
"label": "closeOpenOCDTerminal",
"type": "process",
"command":[
"${command:workbench.action.tasks.terminate}",
// "${command:workbench.action.acceptSelectedQuickOpenItem}" //invalid
]
}
]
}

OpenOCD服务不会像make命令那样自动结束,只依赖于关闭终端或者执行Ctrl+C。调试后如何自动关闭任务终端?或者在任务终端自动执行Ctrl+C命令结束Openocd服务。目前使用的closeOpenOCDTerminal方法需要手动点击弹出列表。

最佳答案

{
"version": "2.0.0",
"tasks": [
{
"label": "start",
"type": "shell",
"command": "make -j4; openocd -f interface/cmsis-dap.cfg -c 'transport select swd' -f target/stm32f1x.cfg",
"isBackground": true,
"problemMatcher": {
"pattern": {
"regexp": "."
},
"background": {
"activeOnStart": true,
"beginsPattern": ".",
"endsPattern": "."
}
}
},
{
"label": "stop",
"command": "echo ${input:terminate}",
"type": "shell",
}
],
"inputs": [
{
"id": "terminate",
"type": "command",
"command": "workbench.action.tasks.terminate",
"args": "terminateAll"
}
]
}

这个例子恰好关闭了任务终端。

关于c - vscode调试后如何自动关闭任务终端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60255906/

47 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com