Correctly place tab stop anchor ranges in snippets with blank lines

This commit is contained in:
Corey Johnson & Nathan Sobo 2013-01-28 16:35:41 -07:00
parent 47ca7f81c1
commit fa8ca1193f
2 changed files with 18 additions and 1 deletions

View File

@ -66,6 +66,15 @@ describe "Snippets extension", ->
${2:placeholder ending second line}
"""
"contains empty lines":
prefix: "t7"
body: """
first line $1
fourth line after blanks $2
"""
describe "when the letters preceding the cursor trigger a snippet", ->
describe "when the snippet contains no tab stops", ->
it "replaces the prefix with the snippet text and places the cursor at its end", ->
@ -140,6 +149,14 @@ describe "Snippets extension", ->
editor.trigger keydownEvent('tab', target: editor[0])
expect(editor.getSelectedBufferRange()).toEqual [[0, 5], [0, 10]]
describe "when tab stops are separated by blank lines", ->
it "correctly places the tab stops (regression)", ->
buffer.setText('')
editor.insertText 't7'
editor.trigger 'snippets:expand'
editor.trigger 'snippets:next-tab-stop'
expect(editSession.getCursorBufferPosition()).toEqual [3, 25]
describe "when the cursor is moved beyond the bounds of a tab stop", ->
it "terminates the snippet", ->
editor.setCursorScreenPosition([2, 0])

View File

@ -30,7 +30,7 @@ class Snippet
bodyText.push(segment)
segmentLines = segment.split('\n')
column += segmentLines.shift().length
while nextLine = segmentLines.shift()
while (nextLine = segmentLines.shift())?
row += 1
column = nextLine.length