Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 19a9448

Browse files
committed
Add regression tests for tab stops at ends of snippets
Adds tests from #261 for an issue that has been since fixed.
1 parent f1386c5 commit 19a9448

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

spec/snippets-spec.coffee

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ describe "Snippets extension", ->
165165
${2:placeholder ending second line}
166166
"""
167167

168+
"tab stops at the ends of snippets":
169+
prefix: "t6b"
170+
body: "$1expanded$0"
171+
172+
"tab stops at the ends of snippets - alternative":
173+
prefix: "t6c"
174+
body: "$0expanded$1"
175+
168176
"contains empty lines":
169177
prefix: "t7"
170178
body: """
@@ -591,6 +599,28 @@ describe "Snippets extension", ->
591599
simulateTabKeyEvent()
592600
expect(editor.lineTextForBufferRow(0)).toBe "first line"
593601

602+
it "does not remember the tab stops when the whole snippet has been undone (regression)", ->
603+
editor.insertText 't6b\n'
604+
editor.setCursorBufferPosition [0, 3]
605+
simulateTabKeyEvent()
606+
expect(editor.lineTextForBufferRow(0)).toBe "expanded"
607+
editor.undo()
608+
expect(editor.lineTextForBufferRow(0)).toBe "t6b"
609+
simulateTabKeyEvent()
610+
expect(editor.lineTextForBufferRow(0)).toBe "expanded"
611+
expect(editor.getCursorBufferPosition()).toEqual([0, 0])
612+
613+
it "does not remember the tab stops when the whole snippet has been undone (regression, alternative version)", ->
614+
editor.insertText 't6c\n'
615+
editor.setCursorBufferPosition [0, 3]
616+
simulateTabKeyEvent()
617+
expect(editor.lineTextForBufferRow(0)).toBe "expanded"
618+
editor.undo()
619+
expect(editor.lineTextForBufferRow(0)).toBe "t6c"
620+
simulateTabKeyEvent()
621+
expect(editor.lineTextForBufferRow(0)).toBe "expanded"
622+
expect(editor.getCursorBufferPosition()).toEqual([0, 8])
623+
594624
describe "when the prefix contains non-word characters", ->
595625
it "selects the non-word characters as part of the prefix", ->
596626
editor.insertText("@unique")

0 commit comments

Comments
 (0)