Skip to content

Commit aae30f7

Browse files
committed
Fix boundary detection logic in findMarks
Closes codemirror#3840
1 parent 68076a8 commit aae30f7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/codemirror.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7622,9 +7622,9 @@
76227622
var spans = line.markedSpans;
76237623
if (spans) for (var i = 0; i < spans.length; i++) {
76247624
var span = spans[i];
7625-
if (!(lineNo == from.line && from.ch > span.to ||
7626-
span.from == null && lineNo != from.line||
7627-
lineNo == to.line && span.from > to.ch) &&
7625+
if (!(span.to != null && lineNo == from.line && from.ch > span.to ||
7626+
span.from == null && lineNo != from.line ||
7627+
span.from != null && lineNo == to.line && span.from > to.ch) &&
76287628
(!filter || filter(span.marker)))
76297629
found.push(span.marker.parent || span.marker);
76307630
}

test/test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,13 @@ testCM("markClearBetween", function(cm) {
509509
eq(cm.findMarksAt(Pos(1, 1)).length, 0);
510510
});
511511

512+
testCM("findMarksMiddle", function(cm) {
513+
var mark = cm.markText(Pos(1, 1), Pos(3, 1));
514+
var found = cm.findMarks(Pos(2, 1), Pos(2, 2));
515+
eq(found.length, 1);
516+
eq(found[0], mark);
517+
}, {value: "line 0\nline 1\nline 2\nline 3"});
518+
512519
testCM("deleteSpanCollapsedInclusiveLeft", function(cm) {
513520
var from = Pos(1, 0), to = Pos(1, 1);
514521
var m = cm.markText(from, to, {collapsed: true, inclusiveLeft: true});

0 commit comments

Comments
 (0)