mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
Always mutate selections in order
This commit is contained in:
@@ -2730,6 +2730,20 @@ describe "TextEditor", ->
|
||||
|
||||
"""
|
||||
|
||||
describe "when many selections get added in shuffle order", ->
|
||||
it "cuts them in order", ->
|
||||
editor.setSelectedBufferRanges([
|
||||
[[2,8], [2, 13]]
|
||||
[[0,4], [0,13]],
|
||||
[[1,6], [1, 10]],
|
||||
])
|
||||
editor.cutSelectedText()
|
||||
expect(atom.clipboard.read()).toEqual """
|
||||
quicksort
|
||||
sort
|
||||
items
|
||||
"""
|
||||
|
||||
describe ".cutToEndOfLine()", ->
|
||||
describe "when soft wrap is on", ->
|
||||
it "cuts up to the end of the line", ->
|
||||
@@ -2900,8 +2914,12 @@ describe "TextEditor", ->
|
||||
editor.setSelectedBufferRanges([[[0, 4], [0, 13]], [[1, 6], [1, 10]]])
|
||||
editor.copySelectedText()
|
||||
|
||||
it "pastes each selection separately into the buffer", ->
|
||||
editor.copySelectedText()
|
||||
it "pastes each selection in order separately into the buffer", ->
|
||||
editor.setSelectedBufferRanges([
|
||||
[[1, 6], [1, 10]]
|
||||
[[0, 4], [0, 13]],
|
||||
])
|
||||
|
||||
editor.moveRight()
|
||||
editor.insertText("_")
|
||||
editor.pasteText()
|
||||
|
||||
@@ -843,7 +843,7 @@ class TextEditor extends Model
|
||||
mutateSelectedText: (fn) ->
|
||||
@mergeIntersectingSelections =>
|
||||
@transact =>
|
||||
fn(selection, index) for selection, index in @getSelections()
|
||||
fn(selection, index) for selection, index in @getSelectionsOrderedByBufferPosition()
|
||||
|
||||
# Move lines intersection the most recent selection up by one row in screen
|
||||
# coordinates.
|
||||
|
||||
Reference in New Issue
Block a user