"Show automatic Python configurations" button does not update when the active editor changes
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript, vscode
调研方向
Read package.json around lines 692–698 and src/extension/extensionInit.ts around lines 245–249 to trace how dynamicPythonConfigAvailable controls the welcome-view button. Compare the two proposed fixes, then check the existing tests for context keys or active-editor changes. Done means the button reflects the active editor’s language and does not offer to run a non-Python file with debugpy.
由索引模型根据 Issue 内容生成。
描述
The extension contributes a "Show automatic Python configurations" button to the welcome view of Run and Debug. The dynamicPythonConfigAvailable context key controls this button:
The extension sets this context key one time, during activation:
No code updates the key after activation. As a result, the button shows the language of the editor that was active when the extension activated, not the language of the current editor. This causes two problems:
- The button stays visible for non-Python files. The extension usually activates through
onLanguage:python, so the key becomestrue. If you then open a JavaScript or TypeScript file, the button stays in the view. - The button can stay hidden for Python files. If the extension activates through a debug activation event while a non-Python file is active, the key becomes
false. The button does not show when you open a Python file later.
Many projects use Python together with other languages, for example a Python backend with a TypeScript frontend. In these projects, the button often shows for files that debugpy cannot debug.
The first problem can also start the wrong program. The button runs workbench.action.debug.selectandstart for debugpy. The first dynamic configuration is "Python Debugger: Python File", with "program": "${file}". If a non-Python file is active, debugpy tries to run that file as Python.
Steps to reproduce
- Open a folder that has a Python file and a non-Python file (for example,
app.pyandindex.js). Do not add alaunch.json. - Open
app.py. - Open the Run and Debug view. The "Show automatic Python configurations" button shows. This is correct.
- Open
index.js. - Look at the Run and Debug view again.
Expected: The button does not show, because the active file is not Python.
Actual: The button continues to show. If you click it and select "Python Debugger: Python File", debugpy tries to run index.js as a Python program.
Possible fixes
I am very happy to contribute a PR for this! Two options seem good from my perspective:
- Update the key when the active editor changes. Add a
window.onDidChangeActiveTextEditorlistener that setsdynamicPythonConfigAvailableagain. This would be the smallest change. - Use the context keys of the workbench. The core debug welcome view already tracks the language of the active editor with
debugStartLanguageanddebuggerInterestedInActiveEditor. Thewhenclause can change todebugStartLanguage == python && debuggerInterestedInActiveEditor && !virtualWorkspace, and the extension can stop setting its own key.
- 主要语言
- TypeScript
- 星标
- 184
- 派生
- 129
- 平均合并
- 4 天 17 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/vscode-python-debugger 的其他 Issue
-
triage-needed
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/vscode-python-debugger#1110 ·
维护者通常 1 天内回复
-
PowerShell script debugpy.ps1 incorrectly handles multiple arguments passed as an array可能已有人在做 @nightcityblade 于 44 天前认领。 未关闭triage-needed
难度 1/5 1-3 小时 新手友好度 88/100
microsoft/vscode-python-debugger#1024 · 1 条评论 ·
维护者通常 1 天内回复
-
Update dependencies with actionable security alerts可能已有人在做 @copilot-swe-agent 于 24 天前认领。 未关闭triage-needed
microsoft/vscode-python-debugger#1111 · 1 个 reaction · 已指派 1 人 ·
维护者通常 1 天内回复
-
Update vulnerable npm dependencies可能重新可做 关联的 PR 已关闭且未合并。 未关闭triage-needed
microsoft/vscode-python-debugger#1104 · 1 个 reaction · 已指派 1 人 ·
维护者通常 1 天内回复
-
triage-needed
难度 4/5 3-5 天 新手友好度 45/100
microsoft/vscode-python-debugger#1052 · 2 条评论 ·
维护者通常 1 天内回复
查看 microsoft/vscode-python-debugger 的全部 Issue
相似的 Issue
-
Table: Space fires onActivate in single-selection mode — the reference doc and the JSDoc disagree未关闭
难度 2/5 1-3 小时 新手友好度 68/100
sidorares/react-x11-components#764 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
backnotprop/plannotator#1840 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
JoviDeCroock/pracht#432 ·
维护者通常 1 天内回复
-
approved check:passed streams:add
难度 1/5 1 小时以内 新手友好度 75/100
维护者通常 1 天内回复
-
Hardware attribute name "app Connection Support" has inconsistent casing可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
walletbeat/walletbeat#1628 ·
维护者通常 1 天内回复