Pass options through to the text buffer

This commit is contained in:
Ben Ogle
2014-10-30 17:49:43 -07:00
parent a466d6cdaf
commit 5231a548e3
2 changed files with 6 additions and 2 deletions

View File

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

View File

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