mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge pull request #4014 from atom/bo-undo-skip
Pass options through to TextBuffer::setTextInRange
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
"serializable": "^1",
|
||||
"space-pen": "3.8.0",
|
||||
"temp": "0.7.0",
|
||||
"text-buffer": "^3.4",
|
||||
"text-buffer": "^3.5",
|
||||
"theorist": "^1.0.2",
|
||||
"underscore-plus": "^1.6.1",
|
||||
"vm-compatibility-layer": "0.1.0"
|
||||
|
||||
@@ -1805,6 +1805,16 @@ describe "TextEditor", ->
|
||||
expect(willInsertSpy).toHaveBeenCalled()
|
||||
expect(didInsertSpy).not.toHaveBeenCalled()
|
||||
|
||||
describe "when the undo option is set to 'skip'", ->
|
||||
beforeEach ->
|
||||
editor.setSelectedBufferRange([[1, 2], [1, 2]])
|
||||
|
||||
it "does not undo the skipped operation", ->
|
||||
range = editor.insertText('x')
|
||||
range = editor.insertText('y', undo: 'skip')
|
||||
editor.undo()
|
||||
expect(buffer.lineForRow(1)).toBe ' yvar sort = function(items) {'
|
||||
|
||||
describe ".insertNewline()", ->
|
||||
describe "when there is a single cursor", ->
|
||||
describe "when the cursor is at the beginning of a line", ->
|
||||
|
||||
@@ -348,6 +348,7 @@ class Selection extends Model
|
||||
# * `autoIndentNewline` if `true`, indent newline appropriately.
|
||||
# * `autoDecreaseIndent` if `true`, decreases indent level appropriately
|
||||
# (for example, when a closing bracket is inserted).
|
||||
# * `normalizeLineEndings` (optional) {Boolean} (default: true)
|
||||
# * `undo` if `skip`, skips the undo stack for this operation.
|
||||
insertText: (text, options={}) ->
|
||||
oldBufferRange = @getBufferRange()
|
||||
@@ -359,7 +360,7 @@ class Selection extends Model
|
||||
if options.indentBasis? and not options.autoIndent
|
||||
text = @normalizeIndents(text, options.indentBasis)
|
||||
|
||||
newBufferRange = @editor.buffer.setTextInRange(oldBufferRange, text, pick(options, 'undo'))
|
||||
newBufferRange = @editor.buffer.setTextInRange(oldBufferRange, text, pick(options, 'undo', 'normalizeLineEndings'))
|
||||
|
||||
if options.select
|
||||
@setBufferRange(newBufferRange, reversed: wasReversed)
|
||||
|
||||
@@ -737,9 +737,12 @@ class TextEditor extends Model
|
||||
#
|
||||
# * `range` A {Range} or range-compatible {Array}.
|
||||
# * `text` A {String}
|
||||
# * `options` (optional) {Object}
|
||||
# * `normalizeLineEndings` (optional) {Boolean} (default: true)
|
||||
# * `undo` (optional) {String} 'skip' will skip the undo system
|
||||
#
|
||||
# Returns the {Range} of the newly-inserted text.
|
||||
setTextInBufferRange: (range, text, normalizeLineEndings) -> @getBuffer().setTextInRange(range, text, normalizeLineEndings)
|
||||
setTextInBufferRange: (range, text, options) -> @getBuffer().setTextInRange(range, text, options)
|
||||
|
||||
# Essential: For each selection, replace the selected text with the given text.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user