diff --git a/spec/extensions/snippets-spec.coffee b/spec/extensions/snippets-spec.coffee index 9d857ba20..1a65f3856 100644 --- a/spec/extensions/snippets-spec.coffee +++ b/spec/extensions/snippets-spec.coffee @@ -116,13 +116,21 @@ describe "Snippets extension", -> describe "when a the start of the snippet is indented", -> - it "indents the subsequent lines of the snippet to be even with the start of the first line", -> - editor.setCursorScreenPosition([2, Infinity]) - editor.insertText ' t3' - editor.trigger 'snippets:expand' - expect(buffer.lineForRow(2)).toBe " if (items.length <= 1) return items; line 1" - expect(buffer.lineForRow(3)).toBe " line 2" - expect(editor.getCursorBufferPosition()).toEqual [3, 12] + describe "when the snippet spans a single line", -> + it "does not indent the next line", -> + editor.setCursorScreenPosition([2, Infinity]) + editor.insertText ' t1' + editor.trigger 'snippets:expand' + expect(buffer.lineForRow(3)).toBe " var pivot = items.shift(), current, left = [], right = [];" + + describe "when the snippet spans multiple lines", -> + it "indents the subsequent lines of the snippet to be even with the start of the first line", -> + editor.setCursorScreenPosition([2, Infinity]) + editor.insertText ' t3' + editor.trigger 'snippets:expand' + expect(buffer.lineForRow(2)).toBe " if (items.length <= 1) return items; line 1" + expect(buffer.lineForRow(3)).toBe " line 2" + expect(editor.getCursorBufferPosition()).toEqual [3, 12] describe "when the letters preceding the cursor don't match a snippet", -> it "inserts a tab as normal", -> diff --git a/src/extensions/snippets/snippet.coffee b/src/extensions/snippets/snippet.coffee index c2bb1f48c..bcdbd3de5 100644 --- a/src/extensions/snippets/snippet.coffee +++ b/src/extensions/snippets/snippet.coffee @@ -27,7 +27,7 @@ class Snippet column += segment.length bodyText.push(lineText.join('')) row++; column = 0 - @lineCount = row + 1 + @lineCount = row @tabStops = [] for index in _.keys(tabStopsByIndex).sort()