From 12dc045329ae051420c94949593c2d74d909e350 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 29 Jul 2015 11:48:33 -0600 Subject: [PATCH] Fix bug where word- and line-wise selections got stuck in reversed state --- spec/text-editor-spec.coffee | 9 +++++++++ src/selection.coffee | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index c314fd271..8a7af3aa7 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -1221,6 +1221,15 @@ describe "TextEditor", -> expect(selection1.getScreenRange()).toEqual [[3, 0], [4, 5]] expect(selection2.getScreenRange()).toEqual [[5, 6], [6, 2]] + describe "when selecting with an initial screen range", -> + it "switches the direction of the selection when selecting to positions before/after the start of the initial range", -> + editor.setCursorScreenPosition([5, 10]) + editor.selectWordsContainingCursors() + editor.selectToScreenPosition([3, 0]) + expect(editor.getLastSelection().isReversed()).toBe true + editor.selectToScreenPosition([9, 0]) + expect(editor.getLastSelection().isReversed()).toBe false + describe ".selectToBeginningOfNextParagraph()", -> it "selects from the cursor to first line of the next paragraph", -> editor.setSelectedBufferRange([[3, 0], [4, 5]]) diff --git a/src/selection.coffee b/src/selection.coffee index 043c88548..6c6609a38 100644 --- a/src/selection.coffee +++ b/src/selection.coffee @@ -198,7 +198,7 @@ class Selection extends Model if position.isLessThan(@initialScreenRange.start) @marker.setScreenRange([position, @initialScreenRange.end], reversed: true) else - @marker.setScreenRange([@initialScreenRange.start, position]) + @marker.setScreenRange([@initialScreenRange.start, position], reversed: false) else @cursor.setScreenPosition(position)