From ca4c40936a9ec534c5d5c02f1cbc6e932279db44 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Mon, 6 Oct 2014 18:19:07 -0700 Subject: [PATCH] Scope editor.autoIndent --- spec/text-editor-spec.coffee | 25 +++++++++++++++++++++++++ src/text-editor.coffee | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 509feacbf..5805eee64 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -3241,6 +3241,31 @@ describe "TextEditor", -> editor.insertText('foo') expect(editor.indentationForBufferRow(2)).toBe editor.indentationForBufferRow(1) + 1 + 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.autoIndent', true) + atom.config.set('.source.coffee', 'editor.autoIndent', false) + + afterEach: -> + atom.packages.deactivatePackages() + atom.packages.unloadPackages() + + it "does not auto-indent the line for javascript files", -> + editor.setCursorBufferPosition([1, 30]) + editor.insertText("\n") + expect(editor.lineTextForBufferRow(2)).toBe " " + + coffeeEditor.setCursorBufferPosition([1, 18]) + coffeeEditor.insertText("\n") + expect(coffeeEditor.lineTextForBufferRow(2)).toBe "" + describe "editor.normalizeIndentOnPaste", -> beforeEach -> atom.config.set('editor.normalizeIndentOnPaste', true) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index a0b561861..9fface7bf 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -2666,7 +2666,7 @@ class TextEditor extends Model ### shouldAutoIndent: -> - atom.config.get("editor.autoIndent") + atom.config.get(@getGrammarScopeDescriptor(), "editor.autoIndent") shouldShowInvisibles: -> not @mini and atom.config.get(@getGrammarScopeDescriptor(), 'editor.showInvisibles')