【发布时间】:2021-03-16 09:50:57
【问题描述】:
我正在为 VS Code 编写一个扩展,基于 sirmspencer's AutoHide,并且 >90% 的调试尝试都失败了。
它启动并工作,但调试器似乎没有附加:
- 断点永远不会被击中,即使扩展主机正在运行它们
- 控制台输出未发送到调试控制台(非常烦人)
- 当我关闭测试窗口并终止进程时,调试器不会收到通知并继续运行
- 当我停止调试器时,测试窗口不会收到通知并保持打开状态
可能是什么问题?
[Video]
这里是.\.vscode: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}" ],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/out/src/**/*.js" ],
"preLaunchTask": "npm"
},
{
"name": "Launch Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/out/test/**/*.js" ],
"preLaunchTask": "npm"
}
]
}
settings.json:
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
}
}
tasks.json:
// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",
// we want to run npm
"command": "npm",
// the command is a shell script
"isShellCommand": true,
// show the output window only if unrecognized errors occur.
"showOutput": "silent",
// we run the custom script "compile" as defined in package.json
"args": ["run", "compile", "--loglevel", "silent"],
// The tsc compiler is started in watching mode
"isWatching": true,
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
}
还有我的package.json:
{
"name": "vscode-hideEmptyErrors",
"displayName": "Hide Empty Problems Panel",
"description": "Hide the 'Problems' panel when there are no relevant errors",
"version": "1.0.0",
"publisher": "Black Platypus",
"repository": {
"url": "https://example.com"
},
"icon": "Images/Icons/Logo_512.png",
"engines": {
"vscode": "^1.43.0"
},
"extensionKind": [
"ui",
"workspace"
],
"categories": [
"Other"
],
"keywords": [
"problems",
"panel",
"hide",
"auto"
],
"activationEvents": [
"*"
],
"main": "./out/src/extension",
"contributes": {
"configuration": {
"type": "object",
"title": "hideEmptyErrors",
"properties": {
"hideEmptyErrors.autoHidePanel": {
"type": "boolean",
"default": true,
"description": "Hide the 'Problems' panel when there are no relevant errors."
},
"hideEmptyErrors.noEditorBehavior": {
"type": "string",
"description": "What should happen when there is no active editor or the active editor has no document while the Problems panel is active?",
"default": "No change",
"enum": [
"No change",
"Hide panel",
"Show Panel"
],
"enumDescriptions": [
"Keeps the panel's current state (visible/hidden)",
"Always hides the panel",
"Always shows the panel"
]
},
"hideEmptyErrors.onlyCountErrorsForCurrentFile": {
"type": "boolean",
"default": true,
"description": "Only count errors for the currently active editor's file."
}
}
},
"commands": [
{
"command": "hideEmptyErrors.toggleHidePanel",
"category": "Auto Hide",
"title": "Toggle Auto Hide Panel for Current Workspace"
}
]
},
"scripts": {
"compile": "tsc -watch -p ./",
"#test": "node ./node_modules/vscode/bin/test",
"vscode:prepublish": "tsc -p ./",
"#postinstall": "node ./node_modules/vscode/bin/install",
"publish": "vsce publish"
},
"devDependencies": {
"@types/mocha": "^2.2.32",
"@types/node": "7.0.7",
"mocha": "^7.2.0",
"typescript": "^2.9.2",
"vscode": "^1.1.36"
}
}
【问题讨论】:
-
我刚刚在一个失败的会话中查看了测试窗口中的开发工具控制台:它显示“找不到用于调试的空闲端口”。调查那个 atm,但遗憾的是,Google 上只出现了一个不相关的 gitHub 问题
标签: debugging visual-studio-code vscode-debugger