Ensure single-line snippets do not indent the following line

This commit is contained in:
Nathan Sobo
2012-06-27 08:03:54 -06:00
parent 79d9faba58
commit 3cce8f9afd
2 changed files with 16 additions and 8 deletions

View File

@@ -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", ->

View File

@@ -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()