mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Merge pull request #8604 from lpommers/pressing-esc-on-multiple-cursors-returns-to-original-cursor-or-selection
Pressing esc on multiple cursors returns to original cursor or selection
This commit is contained in:
commit
575d79acce
@ -1729,7 +1729,7 @@ describe "TextEditor", ->
|
||||
expect(editor.getSelectedBufferRanges()).toEqual [[[0, 0], [0, 3]]]
|
||||
|
||||
describe ".consolidateSelections()", ->
|
||||
it "destroys all selections but the most recent, returning true if any selections were destroyed", ->
|
||||
it "destroys all selections but the least recent, returning true if any selections were destroyed", ->
|
||||
editor.setSelectedBufferRange([[3, 16], [3, 21]])
|
||||
selection1 = editor.getLastSelection()
|
||||
selection2 = editor.addSelectionForBufferRange([[3, 25], [3, 34]])
|
||||
@ -1737,10 +1737,10 @@ describe "TextEditor", ->
|
||||
|
||||
expect(editor.getSelections()).toEqual [selection1, selection2, selection3]
|
||||
expect(editor.consolidateSelections()).toBeTruthy()
|
||||
expect(editor.getSelections()).toEqual [selection3]
|
||||
expect(selection3.isEmpty()).toBeFalsy()
|
||||
expect(editor.getSelections()).toEqual [selection1]
|
||||
expect(selection1.isEmpty()).toBeFalsy()
|
||||
expect(editor.consolidateSelections()).toBeFalsy()
|
||||
expect(editor.getSelections()).toEqual [selection3]
|
||||
expect(editor.getSelections()).toEqual [selection1]
|
||||
|
||||
describe "when the cursor is moved while there is a selection", ->
|
||||
makeSelection = -> selection.setBufferRange [[1, 2], [1, 5]]
|
||||
|
@ -2241,11 +2241,11 @@ class TextEditor extends Model
|
||||
@consolidateSelections()
|
||||
@getLastSelection().clear(options)
|
||||
|
||||
# Reduce multiple selections to the most recently added selection.
|
||||
# Reduce multiple selections to the least recently added selection.
|
||||
consolidateSelections: ->
|
||||
selections = @getSelections()
|
||||
if selections.length > 1
|
||||
selection.destroy() for selection in selections[0...-1]
|
||||
selection.destroy() for selection in selections[1...(selections.length)]
|
||||
true
|
||||
else
|
||||
false
|
||||
|
Loading…
Reference in New Issue
Block a user