From 69214dc26af85c5ed2369e374c6db485e48bc773 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Tue, 5 Dec 2017 23:11:45 +0100 Subject: [PATCH] On clicks, only move cursor if there is one cursor without a selection --- src/text-editor-component.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index da6ec452d..a43616122 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -1758,11 +1758,12 @@ class TextEditorComponent { const screenPosition = this.screenPositionForMouseEvent(event) - // All clicks should set the cursor position, but only left-clicks should - // have additional logic. - // On macOS, ctrl-click brings up the context menu so also handle that case. if (button !== 0 || (platform === 'darwin' && ctrlKey)) { - model.setCursorScreenPosition(screenPosition, {autoscroll: false}) + // Set cursor position only if there is one cursor with no selection + const ranges = model.getSelectedBufferRanges() + if (ranges.length === 1 && ranges[0].isEmpty()) { + model.setCursorScreenPosition(screenPosition, {autoscroll: false}) + } // On Linux, pasting happens on middle click. A textInput event with the // contents of the selection clipboard will be dispatched by the browser