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) <[email protected]>
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
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Anthony Kim (@anthonykim1)Matched files:
|
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
August 16, 2026 22:43
Dmitriy Vasyura (dmitrivMS)
approved these changes
Aug 16, 2026
Copilot started reviewing on behalf of
Dmitriy Vasyura (dmitrivMS)
August 16, 2026 23:14
View session
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 <[email protected]>
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. |
|
Pada Sen, 7 Sep 2026 04.22, Dmitriy Vasyura ***@***.***>
menulis:
… *dmitrivMS* left a comment (microsoft/vscode#318756)
<#318756 (comment)>
Vlad Gerasimov ***@***.***) <https://github.com/vladstudio> Please
accept the terms.
—
Reply to this email directly, view it on GitHub
<#318756?email_source=notifications&email_token=CM7ETLKXXKTUVDRCKBBL5HD5NXISNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNJWGIZDMMBWG4ZKM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#issuecomment-5562260672>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/CM7ETLM2AIO6BPMS642HY535NXISNAVCNFSNUABEKJSXA33TNF2G64TZHM2DCOBYGE4TAMB3JFZXG5LFHM2DKNBRGMYTSOBUGWQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/CM7ETLMIX4C2DU4QEP7ASWL5NXISNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNJWGIZDMMBWG4ZKM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSVGM33PORSXEX3JN5ZQ>
and Android
<https://github.com/notifications/mobile/android/CM7ETLO5ZNG44OT5HWFDZC35NXISNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKNJWGIZDMMBWG4ZKM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSXGM33PORSXEX3BNZSHE33JMQ>.
Download it today!
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
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)