Skip to content

Commit afcbdb6

Browse files
committed
Fix bug in posFromMouse for rectangular coords
It was returning negative values in the ch field. Issue #2485
1 parent 606f55f commit afcbdb6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/codemirror.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2507,7 +2507,7 @@
25072507
var coords = coordsChar(cm, x, y), line;
25082508
if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
25092509
var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
2510-
coords = Pos(coords.line, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff);
2510+
coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
25112511
}
25122512
return coords;
25132513
}

0 commit comments

Comments
 (0)