Using findMarksAt(from, to) to get marker under mouse does not return expected results

I have the following text in CodeMirror, with two different markers, one defined on A, one defined on B (with no space between) :

some text AB sometext
012345678901234567890

Markers are set using markText() as such :
{ line: 0, ch: 10 }, { line: 0, ch: 11 } // A
{ line: 0, ch: 11 }, { line: 0, ch: 12 } // B

If I call findMarksAt({line: 0, ch: 11}), this will return me both markers (A and B), while I expect this should return me only B marker.

I took a look at code and test condition is inclusive (it include both from and to) :

if ((span.from == null || span.from <= pos.ch) &&
            (span.to == null || span.to >= pos.ch))
 { ... }

That is why it returns me both. I use findMarksAt() (along with coordsChar()) to return me which marker is under the mouse cursor. This return me both markers while only one should be returned in my case (A or B, never both)

In your case, maybe, but there’s also cases where other behavior is appropriate. You can use the marks’ find method to determine their precise extent, and filter on that.

Do you mean this method :

doc.findMarks(from: {line, ch}, to: {line, ch}) → array
Returns an array of all the bookmarks and marked ranges found between the given positions (non-inclusive).

AFAIK (maybe I miss something), that one is also inclusive, despite what the documentation says :

if (!(span.to != null && lineNo == from.line && from.ch >= span.to ||
                span.from == null && lineNo != from.line ||
                span.from != null && lineNo == to.line && span.from >= to.ch) &&
              (!filter || filter(span.marker)))
            { ... }

And I cannot use filter callback to exclude “to” part (to be non-inclusive) because callback only give marker element, not the span itself.

No, I mean the find method on the marker objects.

I got it to work. Here is final code in case someone else would need it :

//get the exact text marks under mouse cursor
//should be used inside mouseover() event
var x = e.pageX;
var y = e.pageY;    		
var coords = cm.coordsChar({left: x, top: y});  

//see https://github.com/codemirror/CodeMirror/issues/5010
coords.ch -= (coords.sticky == "before") ? 1 : 0; 
		
var marks = this.cm.findMarksAt(coords) //non-inclusive filter
    .map(x => ({ pos: x.find(), marker:x }))
    .filter(x => coords.ch >= x.pos.from.ch && coords.ch < x.pos.to.ch )
    .map(x => x.marker);