mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Remove getSelectionAtIndex
We’re going to eventually get rid of the clone in getSelections / getCursors freeze those properties and return them directly. Then they can operate on the list garbage free.
This commit is contained in:
parent
9c53d6f014
commit
08388d87c0
@ -814,8 +814,8 @@ describe "EditorComponent", ->
|
||||
it "does not render empty selections", ->
|
||||
editor.addSelectionForBufferRange([[2, 2], [2, 2]])
|
||||
nextAnimationFrame()
|
||||
expect(editor.getSelectionAtIndex(0).isEmpty()).toBe true
|
||||
expect(editor.getSelectionAtIndex(1).isEmpty()).toBe true
|
||||
expect(editor.getSelections()[0].isEmpty()).toBe true
|
||||
expect(editor.getSelections()[1].isEmpty()).toBe true
|
||||
|
||||
expect(componentNode.querySelectorAll('.selection').length).toBe 0
|
||||
|
||||
|
@ -30,7 +30,7 @@ describe "Editor", ->
|
||||
expect(editor2.id).toBe editor.id
|
||||
expect(editor2.getBuffer().getPath()).toBe editor.getBuffer().getPath()
|
||||
expect(editor2.getSelectedBufferRanges()).toEqual [[[1, 2], [3, 4]], [[5, 6], [7, 5]]]
|
||||
expect(editor2.getSelectionAtIndex(1).isReversed()).toBeTruthy()
|
||||
expect(editor2.getSelections()[1].isReversed()).toBeTruthy()
|
||||
expect(editor2.isFoldedAtBufferRow(4)).toBeTruthy()
|
||||
editor2.destroy()
|
||||
|
||||
@ -88,7 +88,7 @@ describe "Editor", ->
|
||||
editor2 = editor.copy()
|
||||
expect(editor2.id).not.toBe editor.id
|
||||
expect(editor2.getSelectedBufferRanges()).toEqual editor.getSelectedBufferRanges()
|
||||
expect(editor2.getSelectionAtIndex(1).isReversed()).toBeTruthy()
|
||||
expect(editor2.getSelections()[1].isReversed()).toBeTruthy()
|
||||
expect(editor2.isFoldedAtBufferRow(4)).toBeTruthy()
|
||||
|
||||
# editor2 can now diverge from its origin edit session
|
||||
|
@ -2083,19 +2083,10 @@ class Editor extends Model
|
||||
getLastSelection: ->
|
||||
_.last(@selections)
|
||||
|
||||
# Extended: Gets the selection at the given index.
|
||||
#
|
||||
# * `index` The index of the selection to return, based on the order in which
|
||||
# the selections were added.
|
||||
#
|
||||
# Returns a {Selection}.
|
||||
getSelectionAtIndex: (index) ->
|
||||
@selections[index]
|
||||
|
||||
# Deprecated:
|
||||
getSelection: (index) ->
|
||||
if index?
|
||||
deprecate("Use Editor::getSelectionAtIndex(index) instead when getting a specific selection at an index")
|
||||
deprecate("Use Editor::getSelections()[index] instead when getting a specific selection")
|
||||
@getSelectionAtIndex(index)
|
||||
else
|
||||
deprecate("Use Editor::getLastSelection() instead")
|
||||
|
Loading…
Reference in New Issue
Block a user