🐛 Always copy selections in order

This commit is contained in:
Antonio Scandurra
2015-04-02 16:28:22 +02:00
parent 7c2b9fa8c4
commit 44d88e082c
2 changed files with 15 additions and 1 deletions

View File

@@ -2792,6 +2792,20 @@ describe "TextEditor", ->
[[5, 8], [5, 8]]
])
describe "when many selections get added in shuffle order", ->
it "copies them in order", ->
editor.setSelectedBufferRanges([
[[2,8], [2, 13]]
[[0,4], [0,13]],
[[1,6], [1, 10]],
])
editor.copySelectedText()
expect(atom.clipboard.read()).toEqual """
quicksort
sort
items
"""
describe ".pasteText()", ->
copyText = (text, {startColumn, textEditor}={}) ->
startColumn ?= 0

View File

@@ -2621,7 +2621,7 @@ class TextEditor extends Model
# Essential: For each selection, copy the selected text.
copySelectedText: ->
maintainClipboard = false
for selection in @getSelections()
for selection in @getSelectionsOrderedByBufferPosition()
if selection.isEmpty()
previousRange = selection.getBufferRange()
selection.selectLine()