diff --git a/lib/ace/mouse/default_handlers.js b/lib/ace/mouse/default_handlers.js index 5b2a8413..e5568881 100644 --- a/lib/ace/mouse/default_handlers.js +++ b/lib/ace/mouse/default_handlers.js @@ -57,7 +57,7 @@ function DefaultHandlers(mouseHandler) { editor.setDefaultHandler("mousewheel", this.onScroll.bind(mouseHandler)); var exports = ["select", "startSelect", "drag", "dragEnd", "dragWait", - "dragWaitEnd", "startDrag"]; + "dragWaitEnd", "startDrag", "focusWait"]; exports.forEach(function(x) { mouseHandler[x] = this[x]; @@ -98,8 +98,9 @@ function DefaultHandlers(mouseHandler) { if (inSelection && !editor.isFocused()) { editor.focus(); if (this.$focusWaitTimout && !this.$clickSelection) { - // todo start select after focusWaitTimout passes - return; + this.setState("focusWait"); + this.captureMouse(ev); + return ev.preventDefault(); } } @@ -212,6 +213,14 @@ function DefaultHandlers(mouseHandler) { editor.keyBinding.addKeyboardHandler(this.$dragKeybinding); }; + this.focusWait = function() { + var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y); + var time = (new Date()).getTime(); + + if (distance > DRAG_OFFSET ||time - this.mousedownEvent.time > this.$focusWaitTimout) + this.startSelect(); + }; + this.dragWait = function() { var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y); var time = (new Date()).getTime(); @@ -219,7 +228,7 @@ function DefaultHandlers(mouseHandler) { if (distance > DRAG_OFFSET) { this.startSelect(); - } else if ((time - this.mousedownEvent.time) > editor.getDragDelay()) { + } else if (time - this.mousedownEvent.time > editor.getDragDelay()) { this.startDrag() } }; diff --git a/lib/ace/range_list.js b/lib/ace/range_list.js index 185ca5a6..8f6f34f6 100644 --- a/lib/ace/range_list.js +++ b/lib/ace/range_list.js @@ -196,10 +196,9 @@ var RangeList = function() { var lineDif = endRow - startRow; var colDiff = -start.column + end.column; - var ranges = this.ranges; - for (var i=0, n = ranges.length; i < n; i++) { + for (var i = 0, n = ranges.length; i < n; i++) { var r = ranges[i]; if (r.end.row < startRow) continue;