问题描述
限时送ChatGPT账号..我在尝试调试一些有角度的打字稿源代码时遇到了 VS 代码调试器的问题,我认为原因是其中一些 VS Code 变量 有错误的值 - 如此处的建议.
我想遵循该建议,但我看不到如何查询 VS 代码变量(例如,显示我的项目的这些变量的当前值).
这些变量之一是
<块引用>${workspaceFolder}
它们用于 VS 代码的配置文件中,例如在 launch.json
文件中.
你知道有没有办法显示这些值?例如,记录这些值或在警报窗口中显示它们就足以让我进行故障排除.
解决方案旧答案:
可能有更好的方法,但您可以运行
//"preLaunchTask": "Echo vars";在您的调试启动中,例如:{名称":Chrome : Launch with sourcemaps",类型":铬",请求":启动",url":http://localhost:3000",webRoot":${workspaceRoot}",sourceMaps":真,运行时参数":[--remote-debugging-port=9222"],preLaunchTask":Echo vars"},
在您的启动任务中,然后在 tasks.json 添加:
<代码>{标签":回声变量",命令":回声",参数":[${env:USERNAME}",workspaceFolder = ${workspaceFolder}"],类型":外壳"},
这些值将被回显到终端.
编辑:
因为更高版本的 vscode 现在支持向终端发送变量,这个更简单的键绑定将在终端中打印出值:
<预><代码>[{键":alt+q",命令":workbench.action.terminal.sendSequence",参数":{//"text": "echo ${env:USERNAME}",//这有效文本":echo file = '${file}':workspaceFolder = '${workspaceFolder}'\u000D"}}]然后 Alt-q 打印出值.
最后的 \u000D
只是一个返回.
I am facing an issue with VS code debugger while trying to debug some angular typescript source code, and I think the reason is that some of those VS Code Variables have the wrong value - as suggested here.
I'd like to follow that advice, but I see no way how to query the VS code variables (e.g. display the current values of these variables for my project).
One of these variables is
${workspaceFolder}
They are used in VS code's config files, for this example in the launch.json
file.
Do you know if there is a way to display those values? For example, log the values or show them in an alert window would just be sufficient for me to troubleshoot it.
解决方案Old answer:
There may be a better way but you could run a
// "preLaunchTask": "Echo vars" in your debug launch like:
{
"name": "Chrome : Launch with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}",
"sourceMaps": true,
"runtimeArgs": [
"--remote-debugging-port=9222"
],
"preLaunchTask": "Echo vars"
},
in your launch task and then in tasks.json add:
{
"label": "Echo vars",
"command": "echo",
"args": [
"${env:USERNAME}",
"workspaceFolder = ${workspaceFolder}"
],
"type": "shell"
},
Those values will be echoed to the terminal.
EDIT:
Because a later version of vscode now supports sending variables to the terminal this simpler keybinding will print out values in the terminal:
[
{
"key": "alt+q",
"command": "workbench.action.terminal.sendSequence",
"args": {
// "text": "echo ${env:USERNAME}", // this works
"text" : "echo file = '${file}' : workspaceFolder = '${workspaceFolder}'\u000D"
}
}
]
then Alt-q prints out the values.
The \u000D
at the end is just a return.
这篇关于如何显示 VS Code 的预定义变量(例如“${workspaceFolder}"或“${fileWorkspaceFolder}")的当前值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论