diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index f39e595ca..7f3978055 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -770,6 +770,23 @@ describe('TextEditorComponent', () => { [[1, 0], [2, 0]] ]) }) + + it('expands the last selection on shift-click', () => { + const {component, element, editor} = buildComponent() + + editor.setCursorScreenPosition([2, 18]) + component.didMouseDownOnLines(Object.assign({ + detail: 1, + shiftKey: true + }, clientPositionForCharacter(component, 1, 4))) + expect(editor.getSelectedScreenRange()).toEqual([[1, 4], [2, 18]]) + + component.didMouseDownOnLines(Object.assign({ + detail: 1, + shiftKey: true + }, clientPositionForCharacter(component, 4, 4))) + expect(editor.getSelectedScreenRange()).toEqual([[2, 18], [4, 4]]) + }) }) }) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index e8ea3c64c..a9515d474 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -742,11 +742,12 @@ class TextEditorComponent { didMouseDownOnLines (event) { const {model} = this.props + const {detail, ctrlKey, shiftKey, metaKey} = event const screenPosition = this.screenPositionForMouseEvent(event) - const addOrRemoveSelection = event.metaKey || (event.ctrlKey && this.getPlatform() !== 'darwin') + const addOrRemoveSelection = metaKey || (ctrlKey && this.getPlatform() !== 'darwin') - switch (event.detail) { + switch (detail) { case 1: if (addOrRemoveSelection) { const existingSelection = model.getSelectionAtScreenPosition(screenPosition) @@ -756,7 +757,11 @@ class TextEditorComponent { model.addCursorAtScreenPosition(screenPosition) } } else { - model.setCursorScreenPosition(screenPosition) + if (shiftKey) { + model.selectToScreenPosition(screenPosition) + } else { + model.setCursorScreenPosition(screenPosition) + } } break case 2: