Fix bug where word- and line-wise selections got stuck in reversed state

This commit is contained in:
Nathan Sobo 2015-07-29 11:48:33 -06:00
parent e187e4bf53
commit 12dc045329
2 changed files with 10 additions and 1 deletions

View File

@ -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]])

View File

@ -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)