解决和调试Visual Studio Code的最佳方法是什么?
在Visual Studio Code中进行编辑时,我在某些代码片段/建议扩展中遇到了冲突,希望尝试找到根本原因。
P.S.对于解决扩展之间的冲突的任何经验,我将不胜感激。如果您之前曾遇到过此问题,请随时鸣叫(内置建议会在几秒钟后完全覆盖扩展建议)
最佳答案
取自https://code.visualstudio.com/docs/extensions/developing-extensions:
Running and debugging your extension
You can easily run your extension under the debugger by pressing F5. This opens a new VS Code window with your extension loaded. Output from your extension shows up in the
Debug Console
. You can set break points, step through your code, and inspect variables either in theDebug
view or theDebug Console
.
要调试已安装的Visual Studio Code扩展,请首先导航到已安装的扩展的项目文件夹。
%USERPROFILE%\.vscode\extension\${PublisherName}.${ExtensionName}-${VersionNumber}\
此文件夹包含在您的用户配置文件或根文件夹中。根据您安装的Visual Studio Code的版本,它也可能称为
.vscode-insiders
。该项目文件夹中应该已经设置了调试器,并设置了,您可以按项目源文件中的F5 来打开
[Extension Development Host]
,就像最初假定的那样。有关更多信息,如果您需要微调这些设置,则可以检查
<projectroot>/.vscode/launch.json
来找到详细说明[Extension Development Host]
用法的启动配置。来自自动生成的扩展调试器设置
launch.json
的示例:// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"configurations": [{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"]
}]
}
从那里开始,只需添加断点和/或控制台日志来找出与扩展相关的问题的原因,这很简单。
〜编辑:我现在有足够的代表来嵌入图像😘
有关Visual Studio Code扩展的一般开发的更多信息,请参见此处的官方文档:
https://code.visualstudio.com/docs/extensions/developing-extensions#_creating-your-own-extension
关于visual-studio-code - 如何调试Visual Studio Code扩展?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51164279/