Snippets parser can parse tab stops in the form of $1, $2, etc.

It associates each tab stop with its position relative to the beginning of the snippet body, and strips the '$number' marker from the inserted snippet body.
This commit is contained in:
Nathan Sobo
2012-06-21 16:33:21 -06:00
parent 2e0943f41a
commit f9ec6214e6
4 changed files with 56 additions and 10 deletions

View File

@@ -85,3 +85,19 @@ describe "Snippets extension", ->
expect(snippet.prefix).toBe 't2'
expect(snippet.description).toBe "Test snippet 2"
expect(snippet.body).toBe "this is a test 2"
it "can parse snippets with tabstops", ->
snippets = Snippets.snippetsParser.parse """
# this line intentially left blank.
snippet t1 "Test snippet 1"
then go back to here: ($2)
first go here: ($1)
endsnippet
"""
snippet = snippets['t1']
expect(snippet.body).toBe """
then go back to here: ()
first go here: ()
"""
expect(snippet.tabStops).toEqual [[1, 16], [0, 23]]