diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 13be7f05b..7c5804bc5 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -3340,6 +3340,13 @@ describe "TextEditor", -> editor.insertText('foo') expect(editor.indentationForBufferRow(2)).toBe editor.indentationForBufferRow(1) + 1 + describe "when pasting", -> + it "auto-indents the pasted text", -> + atom.clipboard.write("console.log(x);\n") + editor.setCursorBufferPosition([5, 2]) + editor.pasteText() + expect(editor.lineTextForBufferRow(5)).toBe(" console.log(x);") + describe 'when scoped settings are used', -> coffeeEditor = null beforeEach -> diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 23e77e2ad..57f47c2f6 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -2507,6 +2507,7 @@ class TextEditor extends Model if containsNewlines or !@getLastCursor().hasPrecedingCharactersOnLine() options.indentBasis ?= metadata.indentBasis + options.autoIndent = @shouldAutoIndent() @insertText(text, options) # Public: For each selection, if the selection is empty, cut all characters