Skip to content

Commit 850d83c

Browse files
authored
Update dynamicPythonConfigAvailable when the active editor changes (#1149)
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 #1122
1 parent 2e48c82 commit 850d83c

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎src/extension/extensionInit.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,15 @@ export async function registerDebugger(context: IExtensionContext): Promise<IExt
242242
}),
243243
);
244244

245-
executeCommand(
246-
'setContext',
247-
'dynamicPythonConfigAvailable',
248-
window.activeTextEditor?.document.languageId === 'python',
249-
);
245+
const updateDynamicPythonConfigAvailable = () => {
246+
executeCommand(
247+
'setContext',
248+
'dynamicPythonConfigAvailable',
249+
window.activeTextEditor?.document.languageId === 'python',
250+
);
251+
};
252+
updateDynamicPythonConfigAvailable();
253+
context.subscriptions.push(window.onDidChangeActiveTextEditor(updateDynamicPythonConfigAvailable));
250254

251255
context.subscriptions.push(
252256
await registerNoConfigDebug(context.environmentVariableCollection, context.extensionPath),

0 commit comments

Comments
 (0)