From 4a67bfcf15d3ac35637b227e570f63e3f3c4f832 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Matt Colyer Date: Tue, 16 Jul 2013 17:08:12 -0700 Subject: [PATCH] Remove editor.autoIndentOnPaste config option Normalize paste on indent covers most use cases of autoindent when pasting. Closes #584 --- spec/app/edit-session-spec.coffee | 45 ------------------------------- src/app/edit-session.coffee | 4 --- src/app/editor.coffee | 1 - src/app/root-view.coffee | 3 --- 4 files changed, 53 deletions(-) diff --git a/spec/app/edit-session-spec.coffee b/spec/app/edit-session-spec.coffee index 798d4430f..e9e74dd52 100644 --- a/spec/app/edit-session-spec.coffee +++ b/spec/app/edit-session-spec.coffee @@ -2334,55 +2334,10 @@ describe "EditSession", -> editSession.insertText('foo') expect(editSession.indentationForBufferRow(2)).toBe editSession.indentationForBufferRow(1) + 1 - describe "editor.autoIndentOnPaste", -> - describe "when the text contains multiple lines", -> - beforeEach -> - copyText("function() {\ninside=true\n}\n i=1\n") - editSession.setCursorBufferPosition([2, 0]) - - it "does not auto-indent pasted text by default", -> - editSession.pasteText() - expect(editSession.lineForBufferRow(2)).toBe "function() {" - expect(editSession.lineForBufferRow(3)).toBe "inside=true" - expect(editSession.lineForBufferRow(4)).toBe "}" - expect(editSession.lineForBufferRow(5)).toBe " i=1" - - it "auto-indents pasted text when editor.autoIndentOnPaste is true", -> - config.set("editor.autoIndentOnPaste", true) - editSession.pasteText() - expect(editSession.lineForBufferRow(2)).toBe " function() {" - expect(editSession.lineForBufferRow(3)).toBe " inside=true" - expect(editSession.lineForBufferRow(4)).toBe " }" - expect(editSession.lineForBufferRow(5)).toBe " i=1" - - describe "when the text contains no newlines", -> - it "increaseses indent of pasted text when editor.autoIndentOnPaste is true", -> - copyText("var number") - editSession.setCursorBufferPosition([10, 0]) - config.set("editor.autoIndentOnPaste", true) - editSession.pasteText() - expect(editSession.lineForBufferRow(10)).toBe " var number" - - it "decreaseses indent of pasted text when editor.autoIndentOnPaste is true", -> - copyText(" var number") - editSession.setCursorBufferPosition([10, 0]) - config.set("editor.autoIndentOnPaste", true) - editSession.pasteText() - expect(editSession.lineForBufferRow(10)).toBe " var number" - describe "editor.normalizeIndentOnPaste", -> beforeEach -> config.set('editor.normalizeIndentOnPaste', true) - it "does not normalize the indentation level of the text when editor.autoIndentOnPaste is true", -> - copyText(" function() {\nvar cool = 1;\n }\n") - config.set('editor.autoIndentOnPaste', true) - editSession.setCursorBufferPosition([5, ]) - editSession.pasteText() - expect(editSession.lineForBufferRow(5)).toBe " function() {" - expect(editSession.lineForBufferRow(6)).toBe " var cool = 1;" - expect(editSession.lineForBufferRow(7)).toBe " }" - it "does not normalize the indentation level of the text when editor.normalizeIndentOnPaste is false", -> copyText(" function() {\nvar cool = 1;\n }\n") config.set('editor.normalizeIndentOnPaste', false) diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 0209e30b5..c38ba063d 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -510,7 +510,6 @@ class EditSession pasteText: (options={}) -> [text, metadata] = pasteboard.read() - options.autoIndent ?= @shouldAutoIndentPastedText() if config.get('editor.normalizeIndentOnPaste') and metadata options.indentBasis ?= metadata.indentBasis @@ -1288,9 +1287,6 @@ class EditSession shouldAutoIndent: -> config.get("editor.autoIndent") - shouldAutoIndentPastedText: -> - config.get("editor.autoIndentOnPaste") - transact: (fn) -> @buffer.transact(fn) commit: -> @buffer.commit() diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 8e076d526..a6a1709c5 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -21,7 +21,6 @@ class Editor extends View showIndentGuide: false showLineNumbers: true autoIndent: true - autoIndentOnPaste: false normalizeIndentOnPaste: true nonWordCharacters: "./\\()\"':,.;<>~!@#$%^&*|+=[]{}`~?-" preferredLineLength: 80 diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 0af310717..eb5ffddf5 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -71,9 +71,6 @@ class RootView extends View @command 'window:toggle-auto-indent', => config.set("editor.autoIndent", !config.get("editor.autoIndent")) - @command 'window:toggle-auto-indent-on-paste', => - config.set("editor.autoIndentOnPaste", !config.get("editor.autoIndentOnPaste")) - @command 'pane:reopen-closed-item', => @panes.reopenItem()