Order the getting ranges / positions by their insertion order

This commit is contained in:
Ben Ogle
2014-09-02 14:38:11 -07:00
parent 659c05c825
commit a7db555030
2 changed files with 10 additions and 10 deletions

View File

@@ -751,17 +751,17 @@ describe "Editor", ->
expect(cursorMovedHandler).not.toHaveBeenCalled()
describe "::getCursorBufferPositions()", ->
it "returns the existing cursor", ->
it "returns the cursor positions in the order they were added", ->
cursor1 = editor.addCursorAtBufferPosition([8, 5])
cursor2 = editor.addCursorAtBufferPosition([4, 5])
expect(editor.getCursorBufferPositions()).toEqual [[0, 0], [4, 5], [8, 5]]
expect(editor.getCursorBufferPositions()).toEqual [[0, 0], [8, 5], [4, 5]]
describe "::getCursorScreenPositions()", ->
it "returns the existing cursor", ->
it "returns the cursor positions in the order they were added", ->
editor.foldBufferRow(4)
cursor1 = editor.addCursorAtBufferPosition([8, 5])
cursor2 = editor.addCursorAtBufferPosition([3, 5])
expect(editor.getCursorScreenPositions()).toEqual [[0, 0], [3, 5], [5, 5]]
expect(editor.getCursorScreenPositions()).toEqual [[0, 0], [5, 5], [3, 5]]
describe "::getCursorsOrderedByBufferPosition()", ->
it "returns all cursors ordered by buffer positions", ->

View File

@@ -1519,9 +1519,9 @@ class Editor extends Model
# Essential: Get the position of all the cursor positions in buffer coordinates.
#
# Returns {Array} of {Point}s
# Returns {Array} of {Point}s in the order they were added
getCursorBufferPositions: ->
cursor.getBufferPosition() for cursor in @getCursorsOrderedByBufferPosition()
cursor.getBufferPosition() for cursor in @getCursors()
# Essential: Move the cursor to the given position in buffer coordinates.
#
@@ -1543,9 +1543,9 @@ class Editor extends Model
# Essential: Get the position of all the cursor positions in screen coordinates.
#
# Returns {Array} of {Point}s
# Returns {Array} of {Point}s in the order the cursors were added
getCursorScreenPositions: ->
cursor.getScreenPosition() for cursor in @getCursorsOrderedByBufferPosition()
cursor.getScreenPosition() for cursor in @getCursors()
# Get the row of the most recently added cursor in screen coordinates.
#
@@ -1816,7 +1816,7 @@ class Editor extends Model
#
# Returns an {Array} of {Range}s.
getSelectedBufferRanges: ->
selection.getBufferRange() for selection in @getSelectionsOrderedByBufferPosition()
selection.getBufferRange() for selection in @getSelections()
# Essential: Set the selected range in buffer coordinates. If there are multiple
# selections, they are reduced to a single selection with the given range.
@@ -1862,7 +1862,7 @@ class Editor extends Model
#
# Returns an {Array} of {Range}s.
getSelectedScreenRanges: ->
selection.getScreenRange() for selection in @getSelectionsOrderedByBufferPosition()
selection.getScreenRange() for selection in @getSelections()
# Essential: Set the selected range in screen coordinates. If there are multiple
# selections, they are reduced to a single selection with the given range.