diff --git a/spec/app/edit-session-spec.coffee b/spec/app/edit-session-spec.coffee index 6d5e6a6f2..ff711b9e9 100644 --- a/spec/app/edit-session-spec.coffee +++ b/spec/app/edit-session-spec.coffee @@ -742,6 +742,13 @@ describe "EditSession", -> describe "when the cursor's current column is greater than the suggested indent level", -> it "preserves the current indent level, indenting all lines relative to it", -> + editSession.insertText('\n ') + editSession.insertText(text, normalizeIndent: true) + + expect(editSession.lineForBufferRow(3)).toBe " while (true) {" + expect(editSession.lineForBufferRow(4)).toBe " foo();" + expect(editSession.lineForBufferRow(5)).toBe " }" + expect(editSession.lineForBufferRow(6)).toBe " bar();" describe "if auto-indent is disabled", -> it "always normalizes indented lines to the cursor's current indentation level", -> diff --git a/src/app/selection.coffee b/src/app/selection.coffee index 01d924c16..b031de7ab 100644 --- a/src/app/selection.coffee +++ b/src/app/selection.coffee @@ -168,11 +168,11 @@ class Selection normalizedLines.join('\n') adjustIndentationForLine: (line, delta) -> - indentText = new Array(Math.abs(delta + 1)).join(' ') + indentText = new Array(Math.abs(delta) + 1).join(' ') if delta > 0 indentText + line else if delta < 0 - line.replace(indentText, '') + line.replace(new RegExp("^#{indentText}"), '') else line