From c01725184ead03a60d19991de1e6465aeb42909f Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 20 Dec 2013 17:17:00 +0400 Subject: [PATCH] remove setTimeout from startSelect fixes #956: double tap regression --- lib/ace/mouse/default_handlers.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/ace/mouse/default_handlers.js b/lib/ace/mouse/default_handlers.js index 0acf64a6..4e28d9d3 100644 --- a/lib/ace/mouse/default_handlers.js +++ b/lib/ace/mouse/default_handlers.js @@ -110,15 +110,13 @@ function DefaultHandlers(mouseHandler) { var editor = this.editor; // allow double/triple click handlers to change selection var shiftPressed = this.mousedownEvent.getShiftKey(); - setTimeout(function(){ - if (shiftPressed) { - editor.selection.selectToPosition(pos); - } - else if (!this.$clickSelection) { - editor.moveCursorToPosition(pos); - editor.selection.clearSelection(); - } - }.bind(this), 0); + if (shiftPressed) { + editor.selection.selectToPosition(pos); + } + else if (!this.$clickSelection) { + editor.moveCursorToPosition(pos); + editor.selection.clearSelection(); + } if (editor.renderer.scroller.setCapture) { editor.renderer.scroller.setCapture(); } @@ -210,13 +208,13 @@ function DefaultHandlers(mouseHandler) { range.start.column--; range.end.column++; } - this.$clickSelection = range; this.setState("select"); - return; + } else { + range = editor.selection.getWordRange(pos.row, pos.column); + this.setState("selectByWords"); } - - this.$clickSelection = editor.selection.getWordRange(pos.row, pos.column); - this.setState("selectByWords"); + this.$clickSelection = range; + this[this.state] && this[this.state](ev); }; this.onTripleClick = function(ev) { @@ -225,6 +223,7 @@ function DefaultHandlers(mouseHandler) { this.setState("selectByLines"); this.$clickSelection = editor.selection.getLineRange(pos.row); + this[this.state] && this[this.state](ev); }; this.onQuadClick = function(ev) {