Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit c8f98d0

Browse files
committed
Prevent the DOM updater from prematurely reusing the composition node
FIX: Fix an issue where changing decorations right before a composition could end up corrupting the visible DOM.
1 parent f3bec86 commit c8f98d0

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/buildtile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ export class TileUpdate {
457457
}
458458
} else if (tile.isText()) {
459459
this.builder.ensureLine(null)
460-
if (!from && to == tile.length) {
460+
if (!from && to == tile.length && !this.cache.reused.has(tile)) {
461461
this.builder.addText(tile.text, activeMarks, openMarks, this.cache.reuse(tile))
462462
} else {
463463
this.cache.add(tile)

src/docview.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ export class DocView {
122122
if (composition || changes.length) {
123123
let oldTile = this.tile
124124
let builder = new TileUpdate(this.view, oldTile, this.blockWrappers, this.decorations, this.dynamicDecorationMap)
125+
if (composition && Tile.get(composition.text))
126+
builder.cache.reused.set(Tile.get(composition.text)!, Reused.DOM)
125127
this.tile = builder.run(changes, composition)
126128
destroyDropped(oldTile, builder.cache.reused)
127129
}

0 commit comments

Comments
 (0)