diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index bdb6b38fc..0caf62ada 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -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 diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 355a644b8..d3b8200ab 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -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()