microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.57k stars 29.01k forks source link

debug.onDidChangeActiveDebugSession not always fired when active session implicitly changes after old active session terminated #231490

Open ahmedneilhussain opened 3 days ago

ahmedneilhussain commented 3 days ago

Does this issue occur when all extensions are disabled?: Yes

Version: 1.94.1 (Universal) Commit: e10f2369d0d9614a452462f2e01cdc4aa9486296 Date: 2024-10-05T05:44:32.189Z Electron: 30.5.1 ElectronBuildId: 10262041 Chromium: 124.0.6367.243 Node.js: 20.16.0 V8: 12.4.254.20-electron.0 OS: Darwin arm64 24.0.0

Steps to Reproduce:

  1. Subscribe to debug.onDidTerminateDebugSession and debug.onDidChangeActiveDebugSession
  2. Start two debug sessions.
  3. Click on the second one in the call stack view to make it active.
  4. Press terminate on the second session via the popup button in the call stack view

Correctly receive the terminate event but not always a active session changed event.

When the second session is killed, the UI correctly reverts to show the state of the first session - so it is now de facto the active one. E.g. variables and buttons update. The combo box in the toolbar updates to reflect the only remaining session (but doesn't disappear, despite there being only one session to show).

It causes us a problem as we have our own custom debug type and a UI panel that we update to reflect the active debug session, showing a diagram relevant to the active session (if one of ours). When the second session is terminated and the first one becomes active by default, we should update the UI as well, but we don't get the event. And because the vscode UI has de facto changed to have the first one active (but without firing an event), there isn't anything the user can do that will trigger that event to fire.

I'm running our extension from vscode in the extension host.

vs-code-engineering[bot] commented 3 days ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.94.2. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

ahmedneilhussain commented 2 days ago

Hi, yes, just seen it in 1.94.2. It didn't occur every time so was hard to be sure. It seems to be an issue more after a 'cold start' with minimal interaction thereafter to trying the sequence above. If I started up with a different workspace then switched then it didn't occur.

Some of the debugger interactions cause a flurry of active editor and focus changes. Dunno if that could be a factor.