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

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.
  • The patch was independently reviewed with Codex (GPT-6 Astra), which verified the event/lifecycle semantics against VS Code's implementation, confirmed there is no registration gap between the initial call and the listener (no intervening await), and exercised the logic across initial states and editor transitions in a mock harness.
  • 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.

This change was prepared with AI assistance (Muse, validated with Codex); 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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

1 participant