From 0ca9d7b97e480471b25542ccb960f6417a17995c Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 19 Nov 2014 09:13:30 -0800 Subject: [PATCH] Remove the `normalizeIndentOnPaste` setting. Always do it. --- spec/text-editor-spec.coffee | 55 +----------------------------------- src/text-editor.coffee | 2 +- 2 files changed, 2 insertions(+), 55 deletions(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 8ff34bacb..fe2bf7857 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -2611,10 +2611,9 @@ describe "TextEditor", -> console.log JSON.stringify(editor.lineTextForBufferRow(1)) expect(editor.lineTextForBufferRow(1)).toBe(" y(); z();") - describe "when `autoIndentOnPaste` is false and `normalizeIndentOnPaste` is true", -> + describe "when `autoIndentOnPaste` is false", -> beforeEach -> atom.config.set('editor.autoIndentOnPaste', false) - atom.config.set('editor.normalizeIndentOnPaste', true) describe "when the inserted text contains no newlines", -> it "does not adjust the indentation level of the text", -> @@ -2672,58 +2671,6 @@ describe "TextEditor", -> expect(editor.lineTextForBufferRow(3)).toBe " }" expect(editor.lineTextForBufferRow(4)).toBe "" - describe 'when scoped settings are used', -> - coffeeEditor = null - beforeEach -> - waitsForPromise -> - atom.packages.activatePackage('language-coffee-script') - waitsForPromise -> - atom.project.open('coffee.coffee', autoIndent: false).then (o) -> - coffeeEditor = o - - runs -> - atom.config.set('.source.js', 'editor.normalizeIndentOnPaste', true) - atom.config.set('.source.coffee', 'editor.normalizeIndentOnPaste', false) - - afterEach: -> - atom.packages.deactivatePackages() - atom.packages.unloadPackages() - - it "normalizes the indentation level based on scoped settings", -> - copyText(" while (true) {\n foo();\n }\n", {startColumn: 2, textEditor: coffeeEditor}) - coffeeEditor.setCursorBufferPosition([4, 4]) - coffeeEditor.pasteText() - expect(coffeeEditor.lineTextForBufferRow(4)).toBe " while (true) {" - expect(coffeeEditor.lineTextForBufferRow(5)).toBe " foo();" - expect(coffeeEditor.lineTextForBufferRow(6)).toBe " }" - - copyText(" while (true) {\n foo();\n }\n", {startColumn: 2}) - editor.setCursorBufferPosition([3, 4]) - editor.pasteText() - expect(editor.lineTextForBufferRow(3)).toBe " while (true) {" - expect(editor.lineTextForBufferRow(4)).toBe " foo();" - expect(editor.lineTextForBufferRow(5)).toBe " }" - - describe "when `autoIndentOnPaste` and `normalizeIndentOnPaste` are both false", -> - beforeEach -> - atom.config.set('editor.normalizeIndentOnPaste', false) - atom.config.set("editor.autoIndentOnPaste", false) - - it "does not auto-indent the pasted text", -> - atom.clipboard.write("console.log(x);\nconsole.log(y);\n") - editor.setCursorBufferPosition([5, 0]) - editor.pasteText() - expect(editor.lineTextForBufferRow(5)).toBe("console.log(x);") - expect(editor.lineTextForBufferRow(6)).toBe("console.log(y);") - - it "does not normalize the indentation level of the text", -> - copyText(" function() {\nvar cool = 1;\n }\n") - editor.setCursorBufferPosition([5, 2]) - editor.pasteText() - expect(editor.lineTextForBufferRow(5)).toBe " function() {" - expect(editor.lineTextForBufferRow(6)).toBe "var cool = 1;" - expect(editor.lineTextForBufferRow(7)).toBe " }" - describe 'when the clipboard has many selections', -> beforeEach -> atom.config.set("editor.autoIndentOnPaste", false) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index a43d5dd50..6701108d0 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -2511,7 +2511,7 @@ class TextEditor extends Model delete options.indentBasis {cursor} = selection - if indentBasis? and atom.config.get(cursor.getScopeDescriptor(), "editor.normalizeIndentOnPaste") + if indentBasis? containsNewlines = text.indexOf('\n') isnt -1 if containsNewlines or !cursor.hasPrecedingCharactersOnLine() options.indentBasis ?= indentBasis