diff --git a/lib/ace/mouse/default_gutter_handler.js b/lib/ace/mouse/default_gutter_handler.js index bf3da956..9437d2e4 100644 --- a/lib/ace/mouse/default_gutter_handler.js +++ b/lib/ace/mouse/default_gutter_handler.js @@ -57,7 +57,8 @@ function GutterHandler(mouseHandler) { } mouseHandler.$clickSelection = editor.selection.getLineRange(row); } - mouseHandler.captureMouse(e, "selectByLines"); + mouseHandler.setState("selectByLines"); + mouseHandler.captureMouse(e); return e.preventDefault(); }); diff --git a/lib/ace/mouse/default_handlers.js b/lib/ace/mouse/default_handlers.js index 9f80e9f4..3e1e5284 100644 --- a/lib/ace/mouse/default_handlers.js +++ b/lib/ace/mouse/default_handlers.js @@ -93,7 +93,14 @@ function DefaultHandlers(mouseHandler) { } } - this.startSelect(pos, true); + if (!inSelection || this.$clickSelection || ev.getShiftKey() || editor.inMultiSelectMode) { + // Directly pick STATE_SELECT, since the user is not clicking inside + // a selection. + this.startSelect(pos); + } else if (inSelection) { + this.mousedownEvent.time = (new Date()).getTime(); + this.startSelect(pos); + } this.captureMouse(ev); return ev.preventDefault(); }; @@ -101,13 +108,16 @@ function DefaultHandlers(mouseHandler) { this.startSelect = function(pos) { pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y); var editor = this.editor; - if (this.mousedownEvent.getShiftKey()) { - editor.selection.selectToPosition(pos); - } - else if (!this.$clickSelection) { - editor.moveCursorToPosition(pos); - editor.selection.clearSelection(); - } + // allow double/triple click handlers to change selection + setTimeout(function(){ + if (this.mousedownEvent.getShiftKey()) { + editor.selection.selectToPosition(pos); + } + else if (!this.$clickSelection) { + editor.moveCursorToPosition(pos); + editor.selection.clearSelection(); + } + }.bind(this), 0); if (editor.container.setCapture) { editor.container.setCapture(); } @@ -221,6 +231,7 @@ function DefaultHandlers(mouseHandler) { editor.selectAll(); this.$clickSelection = editor.getSelectionRange(); this.setState("null"); + this.selectEnd(); }; this.onMouseWheel = function(ev) { diff --git a/lib/ace/mouse/dragdrop_handler.js b/lib/ace/mouse/dragdrop_handler.js index e936c917..41138bee 100644 --- a/lib/ace/mouse/dragdrop_handler.js +++ b/lib/ace/mouse/dragdrop_handler.js @@ -84,6 +84,8 @@ function DragdropHandler(mouseHandler) { var dataTransfer = e.dataTransfer; dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove"; dataTransfer.setDragImage && dataTransfer.setDragImage(proxy, 0, 0); + // clear Opera garbage + dataTransfer.clearData(); dataTransfer.setData("Text", editor.session.getTextRange()); this.setState("drag"); @@ -327,7 +329,8 @@ function DragdropHandler(mouseHandler) { var inSelection = e.inSelection(); var button = e.getButton(); - if (button === 0 && inSelection) { + var clickCount = e.domEvent.detail || 1; + if (clickCount === 1 && button === 0 && inSelection) { this.mousedownEvent.time = (new Date()).getTime(); var eventTarget = e.domEvent.target || e.domEvent.srcElement; if ("unselectable" in eventTarget)