Skip to content

Update dynamicPythonConfigAvailable when the active editor changes - #1149

Open
TEJA P C (PCTEJA) wants to merge 1 commit into
microsoft:mainfrom
PCTEJA:update-dynamic-config-context-1122
Open

TEJA P C (PCTEJA) wants to merge 1 commit into
microsoft:mainfrom
PCTEJA:update-dynamic-config-context-1122

Conversation

@PCTEJA

@PCTEJA TEJA P C (PCTEJA) commented Nov 14, 2026 •

Copy link
Copy Markdown

Summary

Fixes #1122. Implements the first option proposed in that issue ("Update the key when the active editor changes... the smallest change") — credit to the reporter for the analysis and the suggested approach.

The dynamicPythonConfigAvailable context key, which gates the "Show automatic Python configurations" button in the Run and Debug welcome view, was set exactly once during activation from the then-active editor. After that it never changed, so the button:

  • stayed visible for non-Python files (and clicking it could try to run e.g. a JavaScript file as Python), and
  • stayed hidden for Python files if the extension had activated while a non-Python editor was active.

Change

In registerDebugger (src/extension/extensionInit.ts), the one-time setContext call becomes a small local updater that is:

  1. called once at activation (initial behaviour unchanged), and
  2. registered with window.onDidChangeActiveTextEditor, with the disposable added to context.subscriptions.

The updater reads window.activeTextEditor at event time, so closing all editors correctly sets the key to false.

Testing

  • npm run compile-tests (tsc) passes; eslint and prettier --check pass on the changed file.
  • Not done locally: the full VS Code test-host suite (requires downloading a VS Code build). The existing extensionInit unit tests do not cover this context key; adding host-level coverage for it would be a welcome follow-up.

I have reviewed every changed line and take responsibility for it.

The context key gating the 'Show automatic Python configurations'
welcome button was set only once during activation, from whichever
editor was active then. It now also updates on
window.onDidChangeActiveTextEditor, so the button tracks the current
editor's language: hidden for non-Python files and shown for Python
files opened after activation.

Fixes microsoft#1122
@PCTEJA

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@PCTEJA

Copy link
Copy Markdown
Author

Rich Chiodo (@rchiodo) thanks for the approval. One check is still red: Ensure Required Labels — this PR doesn't have an impact label yet, and I don't have permission to add labels in this repo. Could you please add the bug label? This fixes #1122 (the "Show automatic Python configurations" button not updating when the active editor changes). The workflow re-runs when a label is added, so it should go green right after. Everything else passes — tests on Ubuntu and Windows, lint, VSIX and CLA.

@rchiodo Rich Chiodo (rchiodo) added the bug Issue identified by VS Code Team member as probable bug label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants