Merge branch 'master' into mb-tree-sitter-parsers

This commit is contained in:
Max Brunsfeld
2018-01-03 14:53:06 -08:00
4 changed files with 22 additions and 10 deletions

View File

@@ -6,6 +6,6 @@
"url": "https://github.com/atom/atom.git"
},
"dependencies": {
"atom-package-manager": "1.18.12"
"atom-package-manager": "1.19.0"
}
}

View File

@@ -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",
"tree-sitter": "^0.8.4",
"typescript-simple": "1.0.0",
"underscore-plus": "^1.6.6",
@@ -95,7 +95,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",

View File

@@ -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) {')
})
})
})

View File

@@ -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.