From fff5f39db6d28d7c155933a74b15bab0b81d49a4 Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Wed, 3 Jan 2018 11:30:13 -0800 Subject: [PATCH 1/4] :arrow_up: apm@1.19.0 --- apm/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm/package.json b/apm/package.json index d8f4f906e..90093b3d4 100644 --- a/apm/package.json +++ b/apm/package.json @@ -6,6 +6,6 @@ "url": "https://github.com/atom/atom.git" }, "dependencies": { - "atom-package-manager": "1.18.12" + "atom-package-manager": "1.19.0" } } From 3bdda7c5460a2e5f053c1aec426dc60d1b8c1a96 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 3 Jan 2018 13:05:27 -0700 Subject: [PATCH 2/4] :arrow_up: autocomplete-plus --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b767e1a32..c1808fdeb 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "autocomplete-atom-api": "0.10.6", "autocomplete-css": "0.17.5", "autocomplete-html": "0.8.4", - "autocomplete-plus": "2.39.1", + "autocomplete-plus": "2.40.0", "autocomplete-snippets": "1.11.2", "autoflow": "0.29.3", "autosave": "0.24.6", From 75f43b0b0e47641cb0b1b94d68083b2f213e1409 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 3 Jan 2018 12:20:46 -0800 Subject: [PATCH 3/4] :arrow_up: text-buffer --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c1808fdeb..7002ea1c2 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "service-hub": "^0.7.4", "sinon": "1.17.4", "temp": "^0.8.3", - "text-buffer": "13.9.2", + "text-buffer": "13.10.0", "typescript-simple": "1.0.0", "underscore-plus": "^1.6.6", "winreg": "^1.2.1", From 733d6381cc20d9a2cd27ab6fe3a0a0075fca88d6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 3 Jan 2018 13:00:53 -0800 Subject: [PATCH 4/4] Fix handling of {undo: 'skip'} in TextEditor.insertText Signed-off-by: Nathan Sobo --- spec/text-editor-spec.js | 15 +++++++++------ src/text-editor.js | 11 ++++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/spec/text-editor-spec.js b/spec/text-editor-spec.js index ab84d88c8..ef2ced5e6 100644 --- a/spec/text-editor-spec.js +++ b/spec/text-editor-spec.js @@ -3507,13 +3507,16 @@ describe('TextEditor', () => { }) describe("when the undo option is set to 'skip'", () => { - beforeEach(() => editor.setSelectedBufferRange([[1, 2], [1, 2]])) - - it('does not undo the skipped operation', () => { - let range = editor.insertText('x') - range = editor.insertText('y', {undo: 'skip'}) + it('groups the change with the previous change for purposes of undo and redo', () => { + editor.setSelectedBufferRanges([ + [[0, 0], [0, 0]], + [[1, 0], [1, 0]] + ]) + editor.insertText('x') + editor.insertText('y', {undo: 'skip'}) editor.undo() - expect(buffer.lineForRow(1)).toBe(' yvar sort = function(items) {') + expect(buffer.lineForRow(0)).toBe('var quicksort = function () {') + expect(buffer.lineForRow(1)).toBe(' var sort = function(items) {') }) }) }) diff --git a/src/text-editor.js b/src/text-editor.js index 18c767f81..3964323e1 100644 --- a/src/text-editor.js +++ b/src/text-editor.js @@ -1330,15 +1330,24 @@ class TextEditor { insertText (text, options = {}) { if (!this.emitWillInsertTextEvent(text)) return false + let groupLastChanges = false + if (options.undo === 'skip') { + options = Object.assign({}, options) + delete options.undo + groupLastChanges = true + } + const groupingInterval = options.groupUndo ? this.undoGroupingInterval : 0 if (options.autoIndentNewline == null) options.autoIndentNewline = this.shouldAutoIndent() if (options.autoDecreaseIndent == null) options.autoDecreaseIndent = this.shouldAutoIndent() - return this.mutateSelectedText(selection => { + const result = this.mutateSelectedText(selection => { const range = selection.insertText(text, options) const didInsertEvent = {text, range} this.emitter.emit('did-insert-text', didInsertEvent) return range }, groupingInterval) + if (groupLastChanges) this.buffer.groupLastChanges() + return result } // Essential: For each selection, replace the selected text with a newline.