Implement session state tracking for "Run and Debug" button when Inte… - #14719
Implement session state tracking for "Run and Debug" button when Inte…#14719Prashant Kumar Rai (8prashant) wants to merge 2 commits into
Conversation
…lliSense is disabled and add corresponding tests
c556c18 to
47035c5
Compare
There was a problem hiding this comment.
Pull request overview
Ensures Run/Debug editor actions remain available when IntelliSense is disabled.
Changes:
- Tracks active editor changes in the debugger extension.
- Updates build/debug session context keys.
- Adds source, header, non-C/C++, and undefined-editor tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
Extension/src/Debugger/extension.ts |
Adds independent session-state tracking. |
Extension/test/scenarios/SingleRootProject/tests/buildAndDebug.test.ts |
Tests source-file state updates. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sean McManus (sean-mcmanus)
left a comment
There was a problem hiding this comment.
Found one session-state lifecycle gap that should be addressed before merging.
| export function updateBuildAndDebugSessionState(editor?: vscode.TextEditor): void { | ||
| if (editor && isCpp(editor.document)) { | ||
| void SessionState.buildAndDebugIsSourceFile.set(isCppOrCFile(editor.document.uri, editor.document.languageId)); | ||
| void SessionState.buildAndDebugIsFolderOpen.set(isFolderOpen(editor.document.uri)); |
There was a problem hiding this comment.
✨Copilot (agent146): [Moderate] Please keep the folder context key current on every transition that can change isFolderOpen. This listener recomputes it only when the active editor is C/C++, and there is no debugger-side onDidChangeWorkspaceFolders listener. With IntelliSense disabled, opening an in-workspace C++ file sets the key to true; switching to a non-C/C++ editor leaves it true, so the editor context menu still offers C_Cpp.AddDebugConfiguration because that contribution checks only cpptools.buildAndDebug.isFolderOpen. Likewise, adding or removing the active file's workspace folder leaves the key stale until another editor change. Clear/recompute this key for non-C++/undefined editors and recompute it when workspace folders change; the tests should assert the folder key for those transitions as well.
Fixes #13001
When
C_Cpp.intelliSenseEngineis set to"disabled", the language server client is not started. Previously,cpptools.buildAndDebug.isSourceFileandcpptools.buildAndDebug.isFolderOpencontext keys (which control the visibility of the "Run / Debug C/C++ File" and "Add Debug Configuration" editor action buttons) were only updated within the language server client (client.ts). Consequently, disabling IntelliSense would cause the Run/Debug shortcut buttons to never appear in the editor title bar.This PR updates the Debugger extension initialization (
Debugger/extension.ts) to track active text editor changes and keepbuildAndDebugIsSourceFileandbuildAndDebugIsFolderOpenup to date regardless of whether IntelliSense is enabled or disabled.Changes
updateBuildAndDebugSessionStateand registered anonDidChangeActiveTextEditorlistener inDebuggerExtension.initialize.Extension/test/scenarios/SingleRootProject/tests/buildAndDebug.test.tsverifying session state updates for source files, header files, non-C/C++ files, andundefinededitors.Verification
yarn compile) with 0 errors.yarn test --scenario=SingleRootProjectand verified allBuildAndDebug SessionState Testspass.