From 3644a36d671d318ace39baf8ecda8a7779a81e65 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Fri, 11 Apr 2014 09:43:26 -0700 Subject: [PATCH] Clearing a selection will also finalize the selection Fixes #1843 --- spec/editor-view-spec.coffee | 14 ++++++++++++++ src/selection.coffee | 1 + 2 files changed, 15 insertions(+) diff --git a/spec/editor-view-spec.coffee b/spec/editor-view-spec.coffee index af37fa535..6f8f610df 100644 --- a/spec/editor-view-spec.coffee +++ b/spec/editor-view-spec.coffee @@ -464,6 +464,20 @@ describe "EditorView", -> editorView.renderedLines.trigger mousedownEvent(editorView: editorView, point: [3, 12], originalEvent: {detail: 1}, shiftKey: true) expect(editor.getSelectedBufferRange()).toEqual [[3, 10], [3, 12]] + it "stops selecting by word when another selection is made", -> + expect(editor.getCursorScreenPosition()).toEqual(row: 0, column: 0) + editorView.renderedLines.trigger mousedownEvent(editorView: editorView, point: [0, 8], originalEvent: {detail: 1}) + editorView.renderedLines.trigger 'mouseup' + editorView.renderedLines.trigger mousedownEvent(editorView: editorView, point: [0, 8], originalEvent: {detail: 2}) + editorView.renderedLines.trigger 'mouseup' + expect(editor.getSelectedText()).toBe "quicksort" + + editorView.renderedLines.trigger mousedownEvent(editorView: editorView, point: [3, 10]) + editorView.renderedLines.trigger mousemoveEvent(editorView: editorView, point: [3, 12], which: 1) + editorView.renderedLines.trigger 'mouseup' + + expect(editor.getSelectedBufferRange()).toEqual [[3, 10], [3, 12]] + describe "when clicking between a word and a non-word", -> it "selects the word", -> expect(editor.getCursorScreenPosition()).toEqual(row: 0, column: 0) diff --git a/src/selection.coffee b/src/selection.coffee index 795e93004..c6673764b 100644 --- a/src/selection.coffee +++ b/src/selection.coffee @@ -99,6 +99,7 @@ class Selection clear: -> @marker.setAttributes(goalBufferRange: null) @marker.clearTail() unless @retainSelection + @finalize() # Public: Modifies the selection to encompass the current word. #