All tests pass

This commit is contained in:
Holger Rapp 2012-01-18 10:23:42 +01:00
parent 54d946c81e
commit 3c65e369c2
2 changed files with 86 additions and 77 deletions

View File

@ -16,6 +16,9 @@ from UltiSnips.Lexer import tokenize, EscapeCharToken, VisualToken, \
VimLCodeToken, ShellCodeToken VimLCodeToken, ShellCodeToken
from UltiSnips.Util import IndentUtil from UltiSnips.Util import IndentUtil
import sys # TODO
sys.setrecursionlimit(100) # TODO
__all__ = [ "Mirror", "Transformation", "SnippetInstance" ] __all__ = [ "Mirror", "Transformation", "SnippetInstance" ]
from debug import debug from debug import debug
@ -679,6 +682,8 @@ class Visual(NoneditableTextObject):
this will be the empty string this will be the empty string
""" """
def __init__(self, parent, token): def __init__(self, parent, token):
# TODO: rework this: get indent directly from vim buffer and
# only update once.
# Find our containing snippet for visual_content # Find our containing snippet for visual_content
snippet = parent snippet = parent
@ -694,9 +699,12 @@ class Visual(NoneditableTextObject):
NoneditableTextObject.__init__(self, parent, token, initial_text = self._text) NoneditableTextObject.__init__(self, parent, token, initial_text = self._text)
def _do_update(self): def _really_updateman(self, done, not_done):
self.current_text = self._text self._replace_text(TextBuffer(self._text))
self._parent._del_child(self)
return True
# TODO: __repr__ is now basically the same for all elements
def __repr__(self): def __repr__(self):
return "Visual(%s -> %s)" % (self._start, self._end) return "Visual(%s -> %s)" % (self._start, self._end)

151
test.py
View File

@ -1458,81 +1458,82 @@ class TransformationUsingBackspaceToDeleteDefaultValue_ECR(_VimTest):
keys = "test" + EX + BS keys = "test" + EX + BS
wanted = "snip " wanted = "snip "
# End: Transformations #}}} # End: Transformations #}}}
### ${VISUAL} {{{# # ${VISUAL} {{{#
##class Visual_NoVisualSelection_Ignore(_VimTest): class Visual_NoVisualSelection_Ignore(_VimTest):
## snippets = ("test", "h${VISUAL}b") snippets = ("test", "h${VISUAL}b")
## keys = "test" + EX + "abc" keys = "test" + EX + "abc"
## wanted = "hbabc" wanted = "hbabc"
##class Visual_SelectOneWord(_VimTest): class Visual_SelectOneWord(_VimTest):
## snippets = ("test", "h${VISUAL}b") snippets = ("test", "h${VISUAL}b")
## keys = "blablub" + ESC + "0v6l" + EX + "test" + EX keys = "blablub" + ESC + "0v6l" + EX + "test" + EX
## wanted = "hblablubb" wanted = "hblablubb"
##
##class Visual_ExpandTwice(_VimTest): class Visual_ExpandTwice(_VimTest):
## snippets = ("test", "h${VISUAL}b") snippets = ("test", "h${VISUAL}b")
## keys = "blablub" + ESC + "0v6l" + EX + "test" + EX + "\ntest" + EX keys = "blablub" + ESC + "0v6l" + EX + "test" + EX + "\ntest" + EX
## wanted = "hblablubb\nhb" wanted = "hblablubb\nhb"
##
##class Visual_SelectOneWord_TwiceVisual(_VimTest): class Visual_SelectOneWord_TwiceVisual(_VimTest):
## snippets = ("test", "h${VISUAL}b${VISUAL}a") snippets = ("test", "h${VISUAL}b${VISUAL}a")
## keys = "blablub" + ESC + "0v6l" + EX + "test" + EX keys = "blablub" + ESC + "0v6l" + EX + "test" + EX
## wanted = "hblablubbblabluba" wanted = "hblablubbblabluba"
##class Visual_SelectOneWord_Inword(_VimTest): class Visual_SelectOneWord_Inword(_VimTest):
## snippets = ("test", "h${VISUAL}b", "Description", "i") snippets = ("test", "h${VISUAL}b", "Description", "i")
## keys = "blablub" + ESC + "0lv4l" + EX + "test" + EX keys = "blablub" + ESC + "0lv4l" + EX + "test" + EX
## wanted = "bhlablubb" wanted = "bhlablubb"
##class Visual_SelectOneWord_TillEndOfLine(_VimTest): class Visual_SelectOneWord_TillEndOfLine(_VimTest):
## snippets = ("test", "h${VISUAL}b", "Description", "i") snippets = ("test", "h${VISUAL}b", "Description", "i")
## keys = "blablub" + ESC + "0v$" + EX + "test" + EX + ESC + "o" keys = "blablub" + ESC + "0v$" + EX + "test" + EX + ESC + "o"
## wanted = "hblablub\nb" wanted = "hblablub\nb"
##class Visual_SelectOneWordWithTabstop_TillEndOfLine(_VimTest): class Visual_SelectOneWordWithTabstop_TillEndOfLine(_VimTest):
## snippets = ("test", "h${2:ahh}${VISUAL}${1:ups}b", "Description", "i") snippets = ("test", "h${2:ahh}${VISUAL}${1:ups}b", "Description", "i")
## keys = "blablub" + ESC + "0v$" + EX + "test" + EX + "mmm" + JF + "n" + JF + "done" + ESC + "o" keys = "blablub" + ESC + "0v$" + EX + "test" + EX + "mmm" + JF + "n" + JF + "done" + ESC + "o"
## wanted = "hnblablub\nmmmbdone" wanted = "hnblablub\nmmmbdone"
##class Visual_InDefaultText_SelectOneWord_NoOverwrite(_VimTest): class Visual_InDefaultText_SelectOneWord_NoOverwrite(_VimTest):
## snippets = ("test", "h${1:${VISUAL}}b") snippets = ("test", "h${1:${VISUAL}}b")
## keys = "blablub" + ESC + "0v6l" + EX + "test" + EX + JF + "hello" keys = "blablub" + ESC + "0v6l" + EX + "test" + EX + JF + "hello"
## wanted = "hblablubbhello" wanted = "hblablubbhello"
##class Visual_InDefaultText_SelectOneWord(_VimTest): class Visual_InDefaultText_SelectOneWord(_VimTest):
## snippets = ("test", "h${1:${VISUAL}}b") snippets = ("test", "h${1:${VISUAL}}b")
## keys = "blablub" + ESC + "0v6l" + EX + "test" + EX + "hello" keys = "blablub" + ESC + "0v6l" + EX + "test" + EX + "hello"
## wanted = "hhellob" wanted = "hhellob"
##
##class Visual_CrossOneLine(_VimTest): class Visual_CrossOneLine(_VimTest):
## snippets = ("test", "h${VISUAL}b") snippets = ("test", "h${VISUAL}b")
## keys = "bla blub\n helloi" + ESC + "0k4lvjll" + EX + "test" + EX keys = "bla blub\n helloi" + ESC + "0k4lvjll" + EX + "test" + EX
## wanted = "bla hblub\n hellobi" wanted = "bla hblub\n hellobi"
##
##class Visual_LineSelect(_VimTest): # TODO: with indent in default text
## snippets = ("test", "h${VISUAL}b") class Visual_LineSelect(_VimTest):
## keys = "hello\nnice\nworld" + ESC + "Vkk" + EX + "test" + EX snippets = ("test", "h${VISUAL}b")
## wanted = "hhello\nnice\nworld\nb" keys = "hello\nnice\nworld" + ESC + "Vkk" + EX + "test" + EX
##class Visual_InDefaultText_LineSelect_NoOverwrite(_VimTest): wanted = "hhello\nnice\nworld\nb"
## snippets = ("test", "h${1:bef${VISUAL}aft}b") class Visual_InDefaultText_LineSelect_NoOverwrite(_VimTest):
## keys = "hello\nnice\nworld" + ESC + "Vkk" + EX + "test" + EX + JF + "hi" snippets = ("test", "h${1:bef${VISUAL}aft}b")
## wanted = "hbefhello\nnice\nworld\naftbhi" keys = "hello\nnice\nworld" + ESC + "Vkk" + EX + "test" + EX + JF + "hi"
##class Visual_InDefaultText_LineSelect_Overwrite(_VimTest): wanted = "hbefhello\nnice\nworld\naftbhi"
## snippets = ("test", "h${1:bef${VISUAL}aft}b") class Visual_InDefaultText_LineSelect_Overwrite(_VimTest):
## keys = "hello\nnice\nworld" + ESC + "Vkk" + EX + "test" + EX + "jup" + JF + "hi" snippets = ("test", "h${1:bef${VISUAL}aft}b")
## wanted = "hjupbhi" keys = "hello\nnice\nworld" + ESC + "Vkk" + EX + "test" + EX + "jup" + JF + "hi"
##class Visual_LineSelect_CheckIndent(_VimTest): wanted = "hjupbhi"
## snippets = ("test", "beg\n\t${VISUAL}\nend") class Visual_LineSelect_CheckIndent(_VimTest):
## keys = "hello\nnice\nworld" + ESC + "Vkk" + EX + "test" + EX snippets = ("test", "beg\n\t${VISUAL}\nend")
## wanted = "beg\n\thello\n\tnice\n\tworld\nend" keys = "hello\nnice\nworld" + ESC + "Vkk" + EX + "test" + EX
## wanted = "beg\n\thello\n\tnice\n\tworld\nend"
##class Visual_LineSelect_CheckIndentTwice(_VimTest):
## snippets = ("test", "beg\n\t${VISUAL}\nend") class Visual_LineSelect_CheckIndentTwice(_VimTest):
## keys = " hello\n nice\n\tworld" + ESC + "Vkk" + EX + "test" + EX snippets = ("test", "beg\n\t${VISUAL}\nend")
## wanted = "beg\n\t hello\n\t nice\n\t\tworld\nend" keys = " hello\n nice\n\tworld" + ESC + "Vkk" + EX + "test" + EX
## wanted = "beg\n\t hello\n\t nice\n\t\tworld\nend"
##class Visual_LineSelect_WithTabStop(_VimTest):
## snippets = ("test", "beg\n\t${VISUAL}\n\t${1:here_we_go}\nend") class Visual_LineSelect_WithTabStop(_VimTest):
## keys = "hello\nnice\nworld" + ESC + "Vkk" + EX + "test" + EX + "super" + JF + "done" snippets = ("test", "beg\n\t${VISUAL}\n\t${1:here_we_go}\nend")
## wanted = "beg\n\thello\n\tnice\n\tworld\n\tsuper\nenddone" keys = "hello\nnice\nworld" + ESC + "Vkk" + EX + "test" + EX + "super" + JF + "done"
## wanted = "beg\n\thello\n\tnice\n\tworld\n\tsuper\nenddone"
##
##
### End: ${VISUAL} #}}}
# End: ${VISUAL} #}}}
# Recursive (Nested) Snippets {{{# # Recursive (Nested) Snippets {{{#
class RecTabStops_SimpleCase_ExceptCorrectResult(_VimTest): class RecTabStops_SimpleCase_ExceptCorrectResult(_VimTest):