{{ message }}
Repository navigation
Fix terminal-editor shift-drop firing on detached instances - #318756
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits intoSep 8, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
Conversation
…t#311164) `TerminalInstance._dndObserver` was set by `_initDragAndDrop` but never cleared by `detachFromElement`. A `TerminalEditor` pane reuses its `_overflowGuardElement` across tab switches, so when one terminal was detached and another attached to the same container, the old instance's DragAndDropObserver was still listening on it. A shift+drop then fired `sendPath` on every previously-attached terminal in that pane. Disposing the observer on detach removes the listeners from the prior container. Fixes microsoft#311164 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Prevents drag-and-drop listeners from leaking across terminal reattachments by clearing the DnD observer when a terminal detaches from its DOM container.
Changes:
- Clear the terminal instance’s drag-and-drop observer during
detachFromElementto avoid drop events being routed to the wrong instance after reattachment.
Contributor
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
August 16, 2026 22:43
Dmitriy Vasyura (dmitrivMS)
approved these changes
Aug 16, 2026
Contributor
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts:1059
clear()only disposes an observer that already exists.attachToElementdefers_initDragAndDrop(container)withsetTimeout, so a detach in the same turn clears nothing and the queued callback later installs an observer on the detached container, recreating the stale-listener bug. The deferred callback should also verifythis._container === container(or be tracked and cancelled) before initializing.
this._dndObserver.clear();
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
Dmitriy Vasyura (dmitrivMS)
requested changes
Aug 16, 2026
Dmitriy Vasyura (dmitrivMS)
left a comment
Collaborator
There was a problem hiding this comment.
Please add requested test
Ignore deferred drag-and-drop initialization when the terminal has already detached or moved to another container. Add coverage for both established and pending observers during terminal editor tab reuse. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dmitriy Vasyura (dmitrivMS)
approved these changes
Sep 6, 2026
Benjamin Christopher Simmonds (benibenj)
approved these changes
Sep 6, 2026
Collaborator
|
Vlad Gerasimov (@vladstudio) Please accept the terms. |
Dmitriy Vasyura (dmitrivMS)
merged commit Sep 8, 2026
4603a7f
into
microsoft:main
32 of 33 checks passed
Alex Ross (alexr00)
added a commit
that referenced
this pull request
Sep 8, 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.

Summary
Fixes #311164.
TerminalInstance._dndObserver(aMutableDisposable<IDisposable>holding the per-containerDragAndDropObserver) was set by_initDragAndDropbut never cleared bydetachFromElement. Because aTerminalEditorpane reuses its_overflowGuardElementacross tab switches (setInputcallsdetachFromElementon the old instance andattachToElementon the new one against the same container), each newly attached terminal stacked anotherDragAndDropObserveron top of the leaked ones.When the user shift-dropped a file onto the active editor-area terminal, the
EditorDropTargetoverlay correctly disposed itself in dragover, and the drop bubbled to the shared container, where every previously attached terminal's observer fired and calledsendPath.The fix clears the observer on detach and guards the deferred initializer so it cannot install an observer after the terminal has detached or moved to another container.
Test plan
TerminalInstanceunit test file passes (109 passing, 3 pending on the PR head)