Skip to content

fix: prevent terminal panel from overwriting terminalEditorActive context key#304802

Merged
meganrogge merged 3 commits intomicrosoft:mainfrom
yogeshwaran-c:fix/terminal-editor-active-context-key
Mar 28, 2026
Merged

fix: prevent terminal panel from overwriting terminalEditorActive context key#304802
meganrogge merged 3 commits intomicrosoft:mainfrom
yogeshwaran-c:fix/terminal-editor-active-context-key

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

@yogeshwaran-c yogeshwaran-c commented Mar 25, 2026

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When both a terminal editor and a terminal panel are present, focusing the terminal panel incorrectly sets terminalEditorActive to false, even though the active editor is still a terminal editor (activeEditor == terminalEditor). This creates an inconsistent state where activeEditor is terminalEditor but terminalEditorActive is false.

Fixes #182979

What is the new behavior?

The terminalEditorActive context key now correctly reflects whether the active editor is a terminal editor, regardless of which terminal instance is currently focused. Focusing a terminal in the panel no longer overwrites this context key.

Additional context

The root cause was duplicate management of the terminalEditorActive context key:

  1. TerminalEditorService correctly sets it via onDidActiveEditorChange, checking if the active editor is a TerminalEditorInput
  2. TerminalService incorrectly overwrote it via onDidChangeActiveInstance, setting it based on the active terminal instance's target location

When a panel terminal was focused, onDidChangeActiveInstance fired and set terminalEditorActive to false (because the active instance was in the panel), overriding the correct value from TerminalEditorService.

The fix removes the duplicate terminalEditorActive management from TerminalService, leaving it solely to TerminalEditorService which already handles it correctly.

…text key

The terminalEditorActive context key was being incorrectly set to false
when a terminal in the panel received focus, even though the active
editor was still a terminal editor. This happened because
TerminalService listened to onDidChangeActiveInstance and set the key
based on the active terminal instance's location rather than whether the
active editor is a terminal editor.

Remove the duplicate terminalEditorActive management from
TerminalService since TerminalEditorService already correctly manages
this context key via onDidActiveEditorChange, which checks whether the
active editor is a TerminalEditorInput.

Closes microsoft#182979
@vs-code-engineering vs-code-engineering bot added this to the 1.114.0 milestone Mar 25, 2026
@meganrogge meganrogge enabled auto-merge (squash) March 25, 2026 20:55
Copy link
Copy Markdown
Collaborator

@meganrogge meganrogge left a comment

Choose a reason for hiding this comment

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

Thank you!

@yogeshwaran-c
Copy link
Copy Markdown
Contributor Author

The two failing checks (Linux / Electron, Linux / Browser) are transient CI infrastructure failures — the runner received a shutdown signal mid-test ("The runner has received a shutdown signal"), not a test assertion failure. All other platform tests (Windows, macOS, Remote) passed successfully.

Could a maintainer please re-run the failed checks? Thank you!

@meganrogge
Copy link
Copy Markdown
Collaborator

Our pipeline is broken atm

@meganrogge meganrogge merged commit bf4a0eb into microsoft:main Mar 28, 2026
28 of 29 checks passed
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.

Terminal panel overwrites terminalEditorActive context key when a terminal editor is present

3 participants