diff --git a/lib/codemirror.js b/lib/codemirror.js index 63f83be779a7a0b0f686eacdc8933e055dd068e7..138f10d224a3f9e6a9e2f51700aca8abbd01e95f 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -2507,7 +2507,7 @@ var coords = coordsChar(cm, x, y), line; if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; - coords = Pos(coords.line, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff); + coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); } return coords; }