Repository navigation
Keep terminal editors working after moving them to another editor group - #339488
Merged
Megan Rogge (meganrogge) merged 2 commits intoNov 5, 2026
Merged
Megan Rogge (meganrogge) merged 2 commits into
Megan Rogge (meganrogge) merged 2 commits into
Conversation
Moving an editor closes it in the source group with EditorCloseContext.MOVE. TerminalEditorService treated that as a real close and dropped the terminal, so the active terminal became undefined and terminal keybindings such as Cmd+Backspace did nothing until the terminal was refocused. Fixes microsoft#183268
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Anthony Kim (@anthonykim1)Matched files:
|
Contributor
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The targeted lifecycle fix matches editor move semantics and includes focused regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes terminal editor tracking after moves between editor groups.
Changes:
- Ignores
MOVEclose events for terminal editors. - Adds regression coverage for moves and normal closes.
| File | Description |
|---|---|
terminalEditorService.ts |
Preserves terminal tracking during editor moves. |
terminalEditorService.test.ts |
Tests move and close behavior. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Megan Rogge (meganrogge)
approved these changes
Nov 3, 2026
Megan Rogge (meganrogge)
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the fix!
Megan Rogge (meganrogge)
enabled auto-merge (squash)
November 3, 2026 19:31
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 3, 2026
Ben Villalobos (benvillalobos)
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #183268
Summary
If you move a terminal editor to another editor group (with
View: Move Editor into Right Groupand the other move commands, by dragging its tab to another group, or withView: Move Editor into New Window), terminal keybindings that send a sequence to the active terminal stop working. Examples are Cmd+Backspace and Cmd+←/→ on macOS, and Ctrl+Backspace on Windows/Linux. The keypress is swallowed until the terminal loses focus and gets it back. The issue title says Mac, but this happens on every platform.The cause is that
TerminalEditorServicetreats the source half of a move as a real close and stops tracking the terminal. This PR makes it ignore that close.Root cause
An editor moves across groups in two steps in
EditorGroupView.doMoveOrCopyEditorAcrossGroups. The editor first opens in the target group, then closes in the source group withEditorCloseContext.MOVE. TheTerminalEditorInputand its terminal instance are the same objects throughout.TerminalEditorService'sonDidCloseEditorhandler didn't look at the close context. On a move it:_removeInstance, which drops the terminal frominstances, deletes its_editorInputsentry and disposes its focus, dispose and capability listeners;setActiveInstance(undefined), because the moved terminal was the active one.Next the target group activates the editor, and
onDidActiveEditorChangecallssetActiveInstance(instance). The instance is no longer ininstances, so the index is-1andactiveInstancestaysundefined. As a result:ITerminalService.activeInstanceisundefinedwhile a terminal editor is focused, soworkbench.action.terminal.sendSequence(which all of these keybindings use) has no target and does nothing.onDidVisibleEditorsChange. That path only pushes the instance back intoinstances. It doesn't re-register its listeners, soonDidFocusInstance,onDidDisposeInstanceandonDidChangeInstanceCapabilitystay silent for that terminal afterwards.Change
terminalEditorService.ts: theonDidCloseEditorhandler returns early whene.context === EditorCloseContext.MOVE, because the terminal is still open in the editor area.instancesand keeps its input mapping and listeners.onDidActiveEditorChangehandler then re-parents it to the new group (setGroup) and makes it active, as it already does for any activation.terminalEditorService.test.ts: this is the first test suite forTerminalEditorService. It registers a terminal through the realresolveResourcepath and drives the service through itsIEditorServiceevents:keeps a terminal editor tracked and active when it moves to another group: a MOVE close followed by activation in the target group. It fails without this change ({ instances: [], activeInstance: undefined }).removes a terminal editor when it is closed: a normal close still removes the terminal, which guards the existing behavior.I outlined this approach on the issue before starting: #183268 (comment)
What's unchanged
MOVE, so the terminal is removed as beforemoveToTerminalViewremoves it explicitly throughdetachInstanceonDidRequestDetach→detachInstanceMOVEcontext, so it's removed as beforeonDidVisibleEditorsChangepath, which this PR doesn't touchHow to test
Terminal: Create New Terminal in Editor Areatwice.echo hello world), but don't press Enter.View: Move Editor into Right Group.View: Move Editor into Left Group;View: Move Editor into New Window.Terminal: Move Terminal into Panel, or dragging a terminal editor onto the terminal panel, still moves it there without leaving a copy in the editor area.Automated:
Validation
valid-layers-checkandtypecheck-clientpass.Move Editor into New Window, the terminal stays tracked and renders and runs in the new window.