Fixes double clicking on first character of word

This commit is contained in:
Dan Kaplun 2014-05-18 05:17:41 -05:00
parent 593ffa2834
commit 96f55c4fc3

View File

@ -630,16 +630,14 @@ Editor.prototype._initHandlers = function () {
var startX = mouse.x;
var endX = mouse.x + 1;
var prev = word.prev(line, mouse.x);
if (prev) {
if (prev.index < mouse.x && mouse.x < prev.index + prev[0].length) {
var current = word.current(line, mouse.x);
if (current) {
if (prev && current.index < prev.index + prev[0].length) {
startX = prev.index;
endX = prev.index + prev[0].length;
} else {
var current = word.current(line, mouse.x);
if (current && current.index === mouse.x) {
startX = current.index;
endX = current.index + current[0].length;
}
} else if (current.index <= mouse.x && mouse.x < current.index + current[0].length) {
startX = current.index;
endX = current.index + current[0].length;
}
}
self.select({x: startX, y: mouse.y}, {x: endX, y: mouse.y});