merged with trunk

This commit is contained in:
rygwdn@gmail.com 2011-02-28 20:49:15 -04:00
commit da3f4077ee
3 changed files with 60 additions and 9 deletions

View File

@ -17,7 +17,7 @@ UltiSnips *snippet* *snippets* *UltiSnips*
4. Syntax |UltiSnips-syntax|
4.1 Adding Snippets |UltiSnips-adding-snippets|
4.2 Plaintext Snippets |UltiSnips-plaintext-snippets|
4.3 Interpolation |UltiSnips-integration|
4.3 Interpolation |UltiSnips-interpolation|
4.3.1 Shellcode |UltiSnips-shellcode|
4.3.2 VimScript |UltiSnips-vimscript|
4.3.3 Python |UltiSnips-python|

View File

@ -694,8 +694,12 @@ class SnippetManager(object):
this_entered = vim.current.line[:self._vstate.pos.col]
self._chars_entered('\n' + cline + this_entered, 1)
if line_was_shortened and user_didnt_enter_newline:
self._backspace(len(self._vstate.last_line)-len(lline))
self._chars_entered('\n' + cline, 1)
nchars_deleted_in_lline = self._vstate.ppos.col - len(lline)
self._backspace(nchars_deleted_in_lline)
nchars_wrapped_from_lline_after_cursor = \
len(self._vstate.last_line) - self._vstate.ppos.col
self._chars_entered('\n' + cline
[:len(cline)-nchars_wrapped_from_lline_after_cursor], 1)
else:
pentered = lline[self._vstate.ppos.col:]
this_entered = vim.current.line[:self._vstate.pos.col]

59
test.py
View File

@ -23,6 +23,7 @@
#
# The testsuite will use ``screen`` to inject commands into the Vim under test,
# and will compare the resulting output to expected results.
#
import os
import tempfile
@ -146,6 +147,7 @@ class _VimTest(unittest.TestCase):
wanted = ""
keys = ""
sleeptime = 0.00
output = None
def send(self,s):
send(s, self.session)
@ -293,15 +295,60 @@ class MultilineExpandTestTyping_ExceptCorrectResult(_VimTest):
wanted = "Wie Hallo Welt!\nUnd Wie gehtsHuiui! gehts"
keys = "Wie hallo gehts" + ESC + "bhi" + EX + "Huiui!"
class MultilineExpandWithFormatoptionsOn_ExceptCorrectResult(_VimTest):
snippets = ("test", "${1:longer expand}\n$0")
keys = "test" + EX + "This is a longer text that should wrap"
wanted = "This is a longer\ntext that should\nwrap\n"
########################
# Format options tests #
########################
class _FormatoptionsBase(_VimTest):
def _options_on(self):
self.send(":set tw=20\n")
def _options_off(self):
self.send(":set tw=0\n")
class FOSimple_ExceptCorrectResult(_FormatoptionsBase):
snippets = ("test", "${1:longer expand}\n$0")
keys = "test" + EX + "This is a longer text that should wrap"
wanted = "This is a longer\ntext that should\nwrap\n"
class FOTextBeforeAndAfter_ExceptCorrectResult(_FormatoptionsBase):
snippets = ("test", "Before${1:longer expand}After\nstart$1end")
keys = "test" + EX + "This is a longer text that should wrap"
wanted = \
"""BeforeThis is a
longer text that
should wrapAfter
startThis is a
longer text that
should wrapend"""
class FOTextAfter_ExceptCorrectResult(_FormatoptionsBase):
"""Testcase for lp:719998"""
snippets = ("test", "${1:longer expand}after\nstart$1end")
keys = ("test" + EX + "This is a longer snippet that should wrap properly "
"and the mirror below should work as well")
wanted = \
"""This is a longer
snippet that should
wrap properly and
the mirror below
should work as wellafter
startThis is a longer
snippet that should
wrap properly and
the mirror below
should work as wellend"""
class FOWrapOnLongWord_ExceptCorrectResult(_FormatoptionsBase):
"""Testcase for lp:719998"""
snippets = ("test", "${1:longer expand}after\nstart$1end")
keys = ("test" + EX + "This is a longersnippet that should wrap properly")
wanted = \
"""This is a
longersnippet that
should wrap properlyafter
startThis is a
longersnippet that
should wrap properlyend"""
############
# TabStops #
@ -1806,8 +1853,7 @@ class _AnonBase(_VimTest):
self.send(":inoremap <silent> " + EA + ' <C-R>=UltiSnips_Anon('
+ self.args + ')<cr>\n')
def _options_off(self):
self.send(":iunmap <silent> " + EA + ' <C-R>=UltiSnips_Anon('
+ self.args + ')<cr>\n')
self.send(":iunmap <silent> " + EA + '\n')
class Anon_NoTrigger_Simple(_AnonBase):
args = '"simple expand"'
@ -2334,6 +2380,7 @@ if __name__ == '__main__':
# Now, source our runtime
send(":so plugin/UltiSnips.vim\n", options.session)
time.sleep(2) # Parsing and initializing UltiSnips takes a while.
# Inform all test case which screen session to use
suite = unittest.TestSuite()