Repository navigation
Release widget DOM nodes when an editor view is disposed - #337853
Merged
Dmitriy Vasyura (dmitrivMS) merged 2 commits intoSep 25, 2026
Merged
Conversation
Content, overlay and glyph margin widgets outlive the editor view and are only moved into the next view once a new model is attached. Until then their DOM nodes stayed parented in the disposed view (or its overflowing widget containers) and kept the whole previous view DOM alive, e.g. for editors of hidden editor groups. Related to #146841 Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The lifecycle cleanup is correct and regression coverage exercises the affected widget types.
Review effort: Balanced
Findings: 3
Open (3)
What changed in this PR
Prevents editor widget DOM nodes from retaining disposed editor views.
Changes:
- Detaches content, overlay, and glyph-margin widget nodes during view disposal.
- Verifies nodes detach and reattach across model changes.
| File | Description |
|---|---|
contentWidgets.ts |
Releases content widget nodes. |
overlayWidgets.ts |
Releases overlay widget nodes. |
glyphMargin.ts |
Releases glyph-margin widget nodes. |
codeEditorWidget.test.ts |
Tests detachment and reattachment. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <[email protected]>
Dmitriy Vasyura (dmitrivMS)
marked this pull request as ready for review
September 25, 2026 01:35
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
September 25, 2026 01:35
roblourens
approved these changes
Sep 25, 2026
Dmitriy Vasyura (dmitrivMS)
deleted the
agents/leak-editor-widget-dom-view-parts
branch
September 25, 2026 01:47
Abdon Morales (abdonmorales)
pushed a commit
to abdonmorales/vscode-utcs
that referenced
this pull request
Sep 27, 2026
…37853) * Release widget DOM nodes when an editor view is disposed Content, overlay and glyph margin widgets outlive the editor view and are only moved into the next view once a new model is attached. Until then their DOM nodes stayed parented in the disposed view (or its overflowing widget containers) and kept the whole previous view DOM alive, e.g. for editors of hidden editor groups. Related to microsoft#146841 Co-authored-by: Copilot <[email protected]> * Condense widget release comments Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> (cherry picked from commit b5faf95)
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

Related to #146841
Content, overlay and glyph margin widgets outlive the editor
View:CodeEditorWidgetkeeps them and re-adds them to the next view once a model is attached. When a model is detached without a new one (e.g. all editors of a group are closed, the editor stays around without a model), the widgets' DOM nodes stayed parented in the disposed view — or in itsoverflowingContentWidgets/overflowingOverlayWidgetscontainers, which live outside the view's DOM. Since the widgets are referenced by live contributions (rename, suggest, hover, sticky scroll, …), the entire previous view DOM stayed alive.ViewContentWidgets,ViewOverlayWidgetsandGlyphMarginWidgetsnow remove the DOM nodes of their widgets on dispose. Attaching a new model adds them to the new view as before.Retainer path (heap snapshot):
StickyScrollController → StickyScrollWidget._rootDomNode → <div class="sticky-widget"> → overlayWidgets → overflow-guard → <div class="monaco-editor">(same forRenameWidget,SuggestWidget,HoverWidgetvia the overflowing containers)Measurement
One retained view per editor control that is left without a model (e.g. per empty editor group), until a model is attached again.
How this was measured
Code OSS (Electron, dev build) driven over CDP with Playwright. After each scenario: 4× forced GC, then
DOM.getDetachedDomNodes(the data behind Edge's Detached Elements tool), counting the descendants of every detached root. "Without this change" means all other fixes from this series applied and only this one reverted, so the number shows what this retainer alone keeps alive. Each scenario was run 3 times with identical results. The retainer was identified from a heap snapshot retainer path.Added a CodeEditorWidget test with a real view: widget nodes (incl. an overflowing content widget) are released on setModel(null) and reattached on the next setModel.