Skip to content

Commit ac872ce

Browse files
committed
Fix a bug that caused decorations to be split on text node chunk boundaries
FIX: Fix an issue that caused mark decorations longer than 512 characters to needlessly be split. Closes codemirror/dev#1616
1 parent 9ad612a commit ac872ce

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/buildview.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ export class ContentBuilder implements SpanIterator<Decoration> {
8484
this.textOff = 0
8585
}
8686
}
87-
let take = Math.min(this.text.length - this.textOff, length, T.Chunk)
87+
let remaining = Math.min(this.text.length - this.textOff, length)
88+
let take = Math.min(remaining, T.Chunk)
8889
this.flushBuffer(active.slice(active.length - openStart))
8990
this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart)
9091
this.atCursorPos = true
9192
this.textOff += take
9293
length -= take
93-
openStart = 0
94+
openStart = remaining <= take ? 0 : active.length
9495
}
9596
}
9697

0 commit comments

Comments
 (0)