Skip to content

Commit 34e23ed

Browse files
authored
Merge pull request microsoft#238137 from microsoft/tyriar/237527_wrapping_headache
Fix toggling wrapping sometimes losing track of DOM nodes
2 parents 738b906 + a27b338 commit 34e23ed

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/vs/editor/browser/view/viewLayer.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,20 @@ export class VisibleLinesCollection<T extends IVisibleLine> {
277277
return false;
278278
}
279279

280-
public onFlushed(e: viewEvents.ViewFlushedEvent): boolean {
280+
public onFlushed(e: viewEvents.ViewFlushedEvent, flushDom?: boolean): boolean {
281+
// No need to clear the dom node because a full .innerHTML will occur in
282+
// ViewLayerRenderer._render, however the the fallbakc mechanism in the
283+
// GPU renderer may cause this to be necessary as the .innerHTML call
284+
// may not happen depending on the new state, leaving stale DOM nodes
285+
// around.
286+
if (flushDom) {
287+
const start = this._linesCollection.getStartLineNumber();
288+
const end = this._linesCollection.getEndLineNumber();
289+
for (let i = start; i <= end; i++) {
290+
this._linesCollection.getLine(i).getDomNode()?.remove();
291+
}
292+
}
281293
this._linesCollection.flush();
282-
// No need to clear the dom node because a full .innerHTML will occur in ViewLayerRenderer._render
283294
return true;
284295
}
285296

src/vs/editor/browser/viewParts/viewLines/viewLines.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export class ViewLines extends ViewPart implements IViewLines {
254254
return true;
255255
}
256256
public override onFlushed(e: viewEvents.ViewFlushedEvent): boolean {
257-
const shouldRender = this._visibleLines.onFlushed(e);
257+
const shouldRender = this._visibleLines.onFlushed(e, this._viewLineOptions.useGpu);
258258
this._maxLineWidth = 0;
259259
return shouldRender;
260260
}

0 commit comments

Comments
 (0)