@@ -165,6 +165,14 @@ describe "Snippets extension", ->
165
165
${2:placeholder ending second line}
166
166
"""
167
167
168
+ " tab stops at beginning and then end of snippet" :
169
+ prefix : " t6b"
170
+ body : " $1expanded$0"
171
+
172
+ " tab stops at end and then beginning of snippet" :
173
+ prefix : " t6c"
174
+ body : " $0expanded$1"
175
+
168
176
" contains empty lines" :
169
177
prefix : " t7"
170
178
body : """
@@ -585,15 +593,40 @@ describe "Snippets extension", ->
585
593
expect (editor .getSelectedBufferRange ()).toEqual [[0 , 0 ], [0 , 4 ]]
586
594
587
595
describe " when a previous snippet expansion has just been undone" , ->
588
- it " expands the snippet based on the current prefix rather than jumping to the old snippet's tab stop" , ->
589
- editor .insertText ' t6\n '
590
- editor .setCursorBufferPosition [0 , 2 ]
591
- simulateTabKeyEvent ()
592
- expect (editor .lineTextForBufferRow (0 )).toBe " first line"
593
- editor .undo ()
594
- expect (editor .lineTextForBufferRow (0 )).toBe " t6"
595
- simulateTabKeyEvent ()
596
- expect (editor .lineTextForBufferRow (0 )).toBe " first line"
596
+ describe " when the tab stops appear in the middle of the snippet" , ->
597
+ it " expands the snippet based on the current prefix rather than jumping to the old snippet's tab stop" , ->
598
+ editor .insertText ' t6\n '
599
+ editor .setCursorBufferPosition [0 , 2 ]
600
+ simulateTabKeyEvent ()
601
+ expect (editor .lineTextForBufferRow (0 )).toBe " first line"
602
+ editor .undo ()
603
+ expect (editor .lineTextForBufferRow (0 )).toBe " t6"
604
+ simulateTabKeyEvent ()
605
+ expect (editor .lineTextForBufferRow (0 )).toBe " first line"
606
+
607
+ describe " when the tab stops appear at the beginning and then the end of snippet" , ->
608
+ it " expands the snippet based on the current prefix rather than jumping to the old snippet's tab stop" , ->
609
+ editor .insertText ' t6b\n '
610
+ editor .setCursorBufferPosition [0 , 3 ]
611
+ simulateTabKeyEvent ()
612
+ expect (editor .lineTextForBufferRow (0 )).toBe " expanded"
613
+ editor .undo ()
614
+ expect (editor .lineTextForBufferRow (0 )).toBe " t6b"
615
+ simulateTabKeyEvent ()
616
+ expect (editor .lineTextForBufferRow (0 )).toBe " expanded"
617
+ expect (editor .getCursorBufferPosition ()).toEqual ([0 , 0 ])
618
+
619
+ describe " when the tab stops appear at the end and then the beginning of snippet" , ->
620
+ it " expands the snippet based on the current prefix rather than jumping to the old snippet's tab stop" , ->
621
+ editor .insertText ' t6c\n '
622
+ editor .setCursorBufferPosition [0 , 3 ]
623
+ simulateTabKeyEvent ()
624
+ expect (editor .lineTextForBufferRow (0 )).toBe " expanded"
625
+ editor .undo ()
626
+ expect (editor .lineTextForBufferRow (0 )).toBe " t6c"
627
+ simulateTabKeyEvent ()
628
+ expect (editor .lineTextForBufferRow (0 )).toBe " expanded"
629
+ expect (editor .getCursorBufferPosition ()).toEqual ([0 , 8 ])
597
630
598
631
describe " when the prefix contains non-word characters" , ->
599
632
it " selects the non-word characters as part of the prefix" , ->
0 commit comments