From c8ad232c319ed4eea86fad528268a1855153c978 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 17 Nov 2014 08:52:51 -0800 Subject: [PATCH] Respect the editor.autoIndent option when pasting Signed-off-by: Nathan Sobo --- spec/text-editor-spec.coffee | 7 +++++++ src/text-editor.coffee | 1 + 2 files changed, 8 insertions(+) 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