From d55dfc8a6fc8ad9f4d732cac8ad0b70a5f5a8e9a Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Thu, 10 Jan 2013 09:31:23 -0800 Subject: [PATCH] AutoIndent is a config property instead of a syntax property --- spec/app/edit-session-spec.coffee | 27 ++++++++++++++++++++------- src/app/edit-session.coffee | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/spec/app/edit-session-spec.coffee b/spec/app/edit-session-spec.coffee index 9dd4375ab..3de078143 100644 --- a/spec/app/edit-session-spec.coffee +++ b/spec/app/edit-session-spec.coffee @@ -1916,17 +1916,30 @@ describe "EditSession", -> editSession.buffer.reload() expect(editSession.getCursorScreenPosition()).toEqual [0,1] - describe "autoIndent", -> - describe "when editor.autoIndent returns true based on the EditSession's grammar scope", -> - it "auto indents lines", -> - syntax.addProperties("." + editSession.languageMode.grammar.scopeName, editor: autoIndent: true ) + describe "auto-indent", -> + describe "editor.autoIndent", -> + it "auto-indents newlines by default", -> editSession.setCursorBufferPosition([1, 30]) editSession.insertText("\n") expect(editSession.lineForBufferRow(2)).toBe " " - describe "when editor.autoIndent returns false based on the EditSession's grammar scope", -> - it "auto indents lines", -> - syntax.addProperties("." + editSession.languageMode.grammar.scopeName, editor: autoIndent: false ) + it "does not auto-indent newlines if editor.autoIndent is false", -> + config.set("editor.autoIndent", false) editSession.setCursorBufferPosition([1, 30]) editSession.insertText("\n") expect(editSession.lineForBufferRow(2)).toBe "" + + it "auto-indents calls to `indent` by default", -> + editSession.setCursorBufferPosition([1, 30]) + editSession.insertText("\n ") + expect(editSession.lineForBufferRow(2)).toBe " " + editSession.indent() + expect(editSession.lineForBufferRow(2)).toBe " " + + it "does not auto-indents calls to `indent` if editor.autoIndent is false", -> + config.set("editor.autoIndent", false) + editSession.setCursorBufferPosition([1, 30]) + editSession.insertText("\n ") + expect(editSession.lineForBufferRow(2)).toBe " " + editSession.indent() + expect(editSession.lineForBufferRow(2)).toBe " " diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 32c751966..e5d437a23 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -158,7 +158,7 @@ class EditSession logScreenLines: (start, end) -> @displayBuffer.logLines(start, end) shouldAutoIndent: -> - syntax.getProperty(["." + @languageMode.grammar.scopeName], "editor.autoIndent") ? false + config.get("editor.autoIndent") ? true insertText: (text, options={}) -> options.autoIndent ?= @shouldAutoIndent()