"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 於 45 天前認領。 未關閉triage-needed
難度 1/5 1-3 小時 新手友好度 88/100
microsoft/vscode-python-debugger#1024 · 1 則留言 ·
維護者通常 1 天內回覆
-
Update dependencies with actionable security alerts可能已有人在做 @copilot-swe-agent 於 25 天前認領。 未關閉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
-
Bayern feature:Application ready web
難度 2/5 1-3 小時 新手友好度 67/100
digitalfabrik/entitlementcard#3176 ·
維護者通常 7 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
NanmiCoder/cc-haha#1533 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
🐛 Bug: Calendar work items cannot be opened on mobile可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 1/5 1 小時以內 新手友好度 75/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 92/100