Skip to content

Implement session state tracking for "Run and Debug" button when Inte… - #14719

Open
Prashant Kumar Rai (8prashant) wants to merge 7 commits into
microsoft:mainfrom
8prashant:main
Open

Implement session state tracking for "Run and Debug" button when Inte…#14719
Prashant Kumar Rai (8prashant) wants to merge 7 commits into
microsoft:mainfrom
8prashant:main

Conversation

@8prashant

Copy link
Copy Markdown

Fixes #13001

When C_Cpp.intelliSenseEngine is set to "disabled", the language server client is not started. Previously, cpptools.buildAndDebug.isSourceFile and cpptools.buildAndDebug.isFolderOpen context 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 keep buildAndDebugIsSourceFile and buildAndDebugIsFolderOpen up to date regardless of whether IntelliSense is enabled or disabled.

Changes

  1. Added updateBuildAndDebugSessionState and registered an onDidChangeActiveTextEditor listener in DebuggerExtension.initialize.
  2. Added unit tests in Extension/test/scenarios/SingleRootProject/tests/buildAndDebug.test.ts verifying session state updates for source files, header files, non-C/C++ files, and undefined editors.

Verification

  • Compiled with TypeScript (yarn compile) with 0 errors.
  • Ran tests via yarn test --scenario=SingleRootProject and verified all BuildAndDebug SessionState Tests pass.

@github-project-automation github-project-automation Bot moved this to Pull Request in cpptools Aug 30, 2026
@8prashant
Prashant Kumar Rai (8prashant) marked this pull request as ready for review August 30, 2026 18:35
…lliSense is disabled and add corresponding tests

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one session-state lifecycle gap that should be addressed before merging.

Comment thread Extension/src/Debugger/extension.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread Extension/test/scenarios/SingleRootProject/tests/buildAndDebug.test.ts Outdated
Comment thread Extension/src/Debugger/extension.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread Extension/src/Debugger/extension.ts
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active-document language-mode changes can leave the Run/Debug context stale.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread Extension/src/Debugger/extension.ts
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches existing classification behavior and covers the reported regression with focused tests.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@8prashant

Copy link
Copy Markdown
Author

Hi Sean McManus (@sean-mcmanus),
I have addressed all the review feedback
Could you please re-review the updated changes?
Thanks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correctness fixes now look sound. One focused test-coverage gap remains for the new event-driven paths.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨Copilot (agent146): [Minor] Please add focused regression coverage for the event-driven behavior rather than testing only the exported helper. These four tests call updateBuildAndDebugSessionState directly, so they would still pass if any of the new onDidChangeActiveTextEditor, onDidOpenTextDocument, or onDidChangeWorkspaceFolders registrations were absent. They also never use a C++ URI outside the open workspace, so they would have passed the prior global-folder implementation as well. At minimum, add an external C++ source case that asserts isSourceFile === true and isFolderOpen === false, plus one listener-driven transition (ideally an active-document language change while IntelliSense is disabled) to cover the behavior this PR fixes.

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

Labels

None yet

Projects

Status: Pull Request

Development

Successfully merging this pull request may close these issues.

Disabling intellisense disables debugging

3 participants