Snippet mode is now exited after final tabstop zero is encountered.

This commit is contained in:
Michael Henry 2009-08-25 19:18:06 -04:00
parent 4721cb0a9b
commit 66ba0686d9
2 changed files with 16 additions and 10 deletions

View File

@ -479,22 +479,25 @@ class SnippetManager(object):
self._check_if_still_inside_snippet() self._check_if_still_inside_snippet()
def _jump(self, backwards = False): def _jump(self, backwards = False):
jumped = False
if self._cs: if self._cs:
self._expect_move_wo_change = True self._expect_move_wo_change = True
self._ctab = self._cs.select_next_tab(backwards) self._ctab = self._cs.select_next_tab(backwards)
if self._ctab: if self._ctab:
self._vstate.select_span(self._ctab.abs_span) self._vstate.select_span(self._ctab.abs_span)
self._span_selected = self._ctab.abs_span self._span_selected = self._ctab.abs_span
jumped = True
if self._ctab.no == 0:
self._ctab = None
self._csnippets.pop()
self._vstate.update()
else: else:
# This really shouldn't happen, because a snippet should
# have been popped when its final tabstop was used.
# Cleanup by removing current snippet and recursing.
self._csnippets.pop() self._csnippets.pop()
if self._cs: jumped = self._jump(backwards)
self._jump(backwards) return jumped
return True
self._vstate.update()
return True
return False
def _handle_failure(self, trigger): def _handle_failure(self, trigger):
""" """

View File

@ -163,6 +163,11 @@ class DoNotExpandAfterSpace_ExceptCorrectResult(_SimpleExpands):
keys = "hallo " + EX keys = "hallo " + EX
wanted = "hallo " wanted = "hallo "
class ExitSnippetModeAfterTabstopZero(_VimTest):
snippets = ("test", "SimpleText")
keys = "test" + EX + EX
wanted = "SimpleText" + EX
class ExpandInTheMiddleOfLine_ExceptCorrectResult(_SimpleExpands): class ExpandInTheMiddleOfLine_ExceptCorrectResult(_SimpleExpands):
keys = "Wie hallo gehts" + ESC + "bhi" + EX keys = "Wie hallo gehts" + ESC + "bhi" + EX
wanted = "Wie Hallo Welt! gehts" wanted = "Wie Hallo Welt! gehts"
@ -261,12 +266,10 @@ class TabStopUsingBackspaceToDeleteDefaultValueTypeSomethingThen_ECR(_VimTest):
snippets = ("test", "snip ${1/.+/(?0:matched)/} ${1:default}") snippets = ("test", "snip ${1/.+/(?0:matched)/} ${1:default}")
keys = "test" + EX + BS + "hallo" keys = "test" + EX + BS + "hallo"
wanted = "snip matched hallo" wanted = "snip matched hallo"
class TabStopWithOneChar_ExceptCorrectResult(_VimTest): class TabStopWithOneChar_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "nothing ${1:i} hups") snippets = ("hallo", "nothing ${1:i} hups")
keys = "hallo" + EX + "ship" keys = "hallo" + EX + "ship"
wanted = "nothing ship hups" wanted = "nothing ship hups"
class TabStopTestJumping_ExceptCorrectResult(_VimTest): class TabStopTestJumping_ExceptCorrectResult(_VimTest):
snippets = ("hallo", "hallo ${2:End} mitte ${1:Beginning}") snippets = ("hallo", "hallo ${2:End} mitte ${1:Beginning}")
keys = "hallo" + EX + JF + "Test" + JF + "Hi" keys = "hallo" + EX + JF + "Test" + JF + "Hi"