diff --git a/spec/app/edit-session-spec.coffee b/spec/app/edit-session-spec.coffee index f82d7b263..9dd4375ab 100644 --- a/spec/app/edit-session-spec.coffee +++ b/spec/app/edit-session-spec.coffee @@ -1915,3 +1915,18 @@ describe "EditSession", -> editSession.setCursorScreenPosition([0, 1]) 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 ) + 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 ) + editSession.setCursorBufferPosition([1, 30]) + editSession.insertText("\n") + expect(editSession.lineForBufferRow(2)).toBe "" diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 761c6dba8..32c751966 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: -> - false + syntax.getProperty(["." + @languageMode.grammar.scopeName], "editor.autoIndent") ? false insertText: (text, options={}) -> options.autoIndent ?= @shouldAutoIndent()