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()
def _jump(self, backwards = False):
jumped = False
if self._cs:
self._expect_move_wo_change = True
self._ctab = self._cs.select_next_tab(backwards)
if self._ctab:
self._vstate.select_span(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:
# 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()
if self._cs:
self._jump(backwards)
return True
self._vstate.update()
return True
return False
jumped = self._jump(backwards)
return jumped
def _handle_failure(self, trigger):
"""

View File

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