"Show automatic Python configurations" button does not update when the active editor changes
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 72/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- typescript, vscode
- Domínio
- developer-experience
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 182
- Forks
- 125
- Merge médio
- 4d 17h
- PRs com merge (30d)
- 5
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de microsoft/vscode-python-debugger
-
triage-needed
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
microsoft/vscode-python-debugger#1110 ·
Mantenedores costumam responder em até 1 dia
-
PowerShell script debugpy.ps1 incorrectly handles multiple arguments passed as an arrayTalvez já em andamento @nightcityblade assumiu há 43 dias. Abertatriage-needed
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 88/100
microsoft/vscode-python-debugger#1024 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Update dependencies with actionable security alertsTalvez já em andamento @copilot-swe-agent assumiu há 22 dias. Abertatriage-needed
microsoft/vscode-python-debugger#1111 · 1 reação · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Update vulnerable npm dependenciesTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertatriage-needed
microsoft/vscode-python-debugger#1104 · 1 reação · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
triage-needed
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
microsoft/vscode-python-debugger#1052 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de microsoft/vscode-python-debugger
Issues semelhantes
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 75/100
lingdojo/kana-dojo#32018 · 1 comentário · 5 reações ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
paperclipai/paperclip#15751 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
BuilderIO/agent-native#7275 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
Mantenedores costumam responder em até 1 dia