Adjust posFromMouse to handle arbitrary xRel field values

Closes #6067
This commit is contained in:
Marijn Haverbeke 2019-11-19 10:25:13 +01:00
parent 0f191d54ee
commit 18a8ae2f28
1 changed files with 1 additions and 1 deletions

View File

@ -679,7 +679,7 @@ export function posFromMouse(cm, e, liberal, forRect) {
try { x = e.clientX - space.left; y = e.clientY - space.top }
catch (e) { return null }
let coords = coordsChar(cm, x, y), line
if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
if (forRect && coords.xRel > 0 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
let colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length
coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff))
}