Respect format-preserving options in TextEditor.pasteText

This commit is contained in:
Nathan Sobo
2017-10-23 17:02:41 -06:00
parent bbbf09ecf2
commit 6701644bbd
2 changed files with 16 additions and 2 deletions

View File

@@ -3247,12 +3247,13 @@ class TextEditor extends Model
# corresponding clipboard selection text.
#
# * `options` (optional) See {Selection::insertText}.
pasteText: (options={}) ->
pasteText: (options) ->
options = Object.assign({}, options)
{text: clipboardText, metadata} = @constructor.clipboard.readWithMetadata()
return false unless @emitWillInsertTextEvent(clipboardText)
metadata ?= {}
options.autoIndent = @shouldAutoIndentOnPaste()
options.autoIndent ?= @shouldAutoIndentOnPaste()
@mutateSelectedText (selection, index) =>
if metadata.selections?.length is @getSelections().length