"Show automatic Python configurations" button does not update when the active editor changes
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 72/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- typescript, vscode
- Domaine
- developer-experience
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- TypeScript
- Étoiles
- 182
- Forks
- 125
- Merge moyen
- 4 j 17 h
- PR mergées (30 j)
- 5
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de microsoft/vscode-python-debugger
-
triage-needed
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
microsoft/vscode-python-debugger#1110 ·
Les mainteneurs répondent en général sous 1 jour
-
PowerShell script debugpy.ps1 incorrectly handles multiple arguments passed as an arrayPeut-être pris @nightcityblade l’a pris il y a 43 jours. Ouvertetriage-needed
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
microsoft/vscode-python-debugger#1024 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Update dependencies with actionable security alertsPeut-être pris @copilot-swe-agent l’a pris il y a 22 jours. Ouvertetriage-needed
microsoft/vscode-python-debugger#1111 · 1 réaction · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Update vulnerable npm dependenciesPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouvertetriage-needed
microsoft/vscode-python-debugger#1104 · 1 réaction · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
triage-needed
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
microsoft/vscode-python-debugger#1052 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de microsoft/vscode-python-debugger
Issues similaires
-
[Docs] README: FAQ setup command, IDA in the intro, Node badgePeut-être pris @akram1089 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
morluto/rea#1353 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
[Feature]: [P3] engine-rs: the package source hash should ignore line endings and untracked filesOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
maniator/verticopolis#880 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
siyuan-note/siyuan#20353 ·
Les mainteneurs répondent en général sous 1 jour
-
afk-ok area:data-quality importer size:S
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
enorm-labs/event-junkie#3027 ·
Les mainteneurs répondent en général sous 1 jour