Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

"Show automatic Python configurations" button does not update when the active editor changes

オープン
#1,122 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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 の本文から書いたものです。

説明

triage-needed

The extension contributes a "Show automatic Python configurations" button to the welcome view of Run and Debug. The dynamicPythonConfigAvailable context key controls this button:

https://github.com/microsoft/vscode-python-debugger/blob/3351fdf239de2111c7033cfe0ef386b058de4c7f/package.json#L692-L698

The extension sets this context key one time, during activation:

https://github.com/microsoft/vscode-python-debugger/blob/3351fdf239de2111c7033cfe0ef386b058de4c7f/src/extension/extensionInit.ts#L245-L249

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:

  1. The button stays visible for non-Python files. The extension usually activates through onLanguage:python, so the key becomes true. If you then open a JavaScript or TypeScript file, the button stays in the view.
  2. 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
  1. Open a folder that has a Python file and a non-Python file (for example, app.py and index.js). Do not add a launch.json.
  2. Open app.py.
  3. Open the Run and Debug view. The "Show automatic Python configurations" button shows. This is correct.
  4. Open index.js.
  5. 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.onDidChangeActiveTextEditor listener that sets dynamicPythonConfigAvailable again. 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 debugStartLanguage and debuggerInterestedInActiveEditor. The when clause can change to debugStartLanguage == python && debuggerInterestedInActiveEditor && !virtualWorkspace, and the extension can stop setting its own key.
主要言語
TypeScript
スター
182
フォーク
125
平均マージ
4日 17時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/vscode-python-debugger のほかの issue

microsoft/vscode-python-debugger の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。