Skip to content

Commit 4e130aa

Browse files
committed
Fix a bug in MatchDecorator where deletions might break updates
FIX: Fix an issue in `MatchDecorator` causing `updateDeco` to sometimes not do the right thing for deletions. See https://discuss.codemirror.net/t/bug-with-highlighttrailingwhitespace-and-entering-a-new-line-and-pressing-command-z/9213
1 parent 3738449 commit 4e130aa

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/highlight-space.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ export function highlightWhitespace() {
3333

3434
const trailingHighlighter = matcher(new MatchDecorator({
3535
regexp: /\s+$/g,
36-
decoration: Decoration.mark({class: "cm-trailingSpace"}),
37-
boundary: /\S/,
36+
decoration: Decoration.mark({class: "cm-trailingSpace"})
3837
}))
3938

4039
/// Returns an extension that adds a `cm-trailingSpace` class to all

src/matchdecorator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class MatchDecorator {
118118
private updateRange(view: EditorView, deco: DecorationSet, updateFrom: number, updateTo: number) {
119119
for (let r of view.visibleRanges) {
120120
let from = Math.max(r.from, updateFrom), to = Math.min(r.to, updateTo)
121-
if (to > from) {
121+
if (to >= from) {
122122
let fromLine = view.state.doc.lineAt(from), toLine = fromLine.to < to ? view.state.doc.lineAt(to) : fromLine
123123
let start = Math.max(r.from, fromLine.from), end = Math.min(r.to, toLine.to)
124124
if (this.boundary) {

0 commit comments

Comments
 (0)