From 193fd14e7917c26e3049fb6dc2c6196c18fc017c Mon Sep 17 00:00:00 2001 From: Luke Pommersheim Date: Mon, 31 Aug 2015 20:21:43 +0200 Subject: [PATCH 1/3] reduce multiple cursors/selections to the first, original, cursor/selection --- src/text-editor.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 9dcc7cb62..10a60632f 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -2270,11 +2270,11 @@ class TextEditor extends Model @consolidateSelections() @getLastSelection().clear(options) - # Reduce multiple selections to the most recently added selection. + # Reduce multiple selections to the first, original 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 From 7822e2c6768ffd7009a70414917dab94fc67f1ec Mon Sep 17 00:00:00 2001 From: Luke Pommersheim Date: Mon, 31 Aug 2015 20:22:24 +0200 Subject: [PATCH 2/3] :tulip: change the spec for consolidateSelections --- spec/text-editor-spec.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 7d9e17dc2..b44edab4b 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -1883,7 +1883,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 until the first, original, selections returning true if any selections were destroyed", -> editor.setSelectedBufferRange([[3, 16], [3, 21]]) selection1 = editor.getLastSelection() selection2 = editor.addSelectionForBufferRange([[3, 25], [3, 34]]) @@ -1891,10 +1891,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]] From 1b07093cff504d060ddbffbdf3c448ae83af3b4d Mon Sep 17 00:00:00 2001 From: Luke Pommersheim Date: Wed, 23 Sep 2015 11:01:49 +0200 Subject: [PATCH 3/3] update comments --- spec/text-editor-spec.coffee | 2 +- src/text-editor.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 04cbeede4..3361ae77d 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -1890,7 +1890,7 @@ describe "TextEditor", -> expect(editor.getSelectedBufferRanges()).toEqual [[[0, 0], [0, 3]]] describe ".consolidateSelections()", -> - it "destroys all selections until the first, original, selections 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]]) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index ef3b18a92..df38d0bcd 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -2264,7 +2264,7 @@ class TextEditor extends Model @consolidateSelections() @getLastSelection().clear(options) - # Reduce multiple selections to the first, original selection. + # Reduce multiple selections to the least recently added selection. consolidateSelections: -> selections = @getSelections() if selections.length > 1