merged with trunk
This commit is contained in:
commit
da3f4077ee
@ -17,7 +17,7 @@ UltiSnips *snippet* *snippets* *UltiSnips*
|
|||||||
4. Syntax |UltiSnips-syntax|
|
4. Syntax |UltiSnips-syntax|
|
||||||
4.1 Adding Snippets |UltiSnips-adding-snippets|
|
4.1 Adding Snippets |UltiSnips-adding-snippets|
|
||||||
4.2 Plaintext Snippets |UltiSnips-plaintext-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.1 Shellcode |UltiSnips-shellcode|
|
||||||
4.3.2 VimScript |UltiSnips-vimscript|
|
4.3.2 VimScript |UltiSnips-vimscript|
|
||||||
4.3.3 Python |UltiSnips-python|
|
4.3.3 Python |UltiSnips-python|
|
||||||
|
@ -694,8 +694,12 @@ class SnippetManager(object):
|
|||||||
this_entered = vim.current.line[:self._vstate.pos.col]
|
this_entered = vim.current.line[:self._vstate.pos.col]
|
||||||
self._chars_entered('\n' + cline + this_entered, 1)
|
self._chars_entered('\n' + cline + this_entered, 1)
|
||||||
if line_was_shortened and user_didnt_enter_newline:
|
if line_was_shortened and user_didnt_enter_newline:
|
||||||
self._backspace(len(self._vstate.last_line)-len(lline))
|
nchars_deleted_in_lline = self._vstate.ppos.col - len(lline)
|
||||||
self._chars_entered('\n' + cline, 1)
|
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:
|
else:
|
||||||
pentered = lline[self._vstate.ppos.col:]
|
pentered = lline[self._vstate.ppos.col:]
|
||||||
this_entered = vim.current.line[:self._vstate.pos.col]
|
this_entered = vim.current.line[:self._vstate.pos.col]
|
||||||
|
59
test.py
59
test.py
@ -23,6 +23,7 @@
|
|||||||
#
|
#
|
||||||
# The testsuite will use ``screen`` to inject commands into the Vim under test,
|
# The testsuite will use ``screen`` to inject commands into the Vim under test,
|
||||||
# and will compare the resulting output to expected results.
|
# and will compare the resulting output to expected results.
|
||||||
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -146,6 +147,7 @@ class _VimTest(unittest.TestCase):
|
|||||||
wanted = ""
|
wanted = ""
|
||||||
keys = ""
|
keys = ""
|
||||||
sleeptime = 0.00
|
sleeptime = 0.00
|
||||||
|
output = None
|
||||||
|
|
||||||
def send(self,s):
|
def send(self,s):
|
||||||
send(s, self.session)
|
send(s, self.session)
|
||||||
@ -293,15 +295,60 @@ class MultilineExpandTestTyping_ExceptCorrectResult(_VimTest):
|
|||||||
wanted = "Wie Hallo Welt!\nUnd Wie gehtsHuiui! gehts"
|
wanted = "Wie Hallo Welt!\nUnd Wie gehtsHuiui! gehts"
|
||||||
keys = "Wie hallo gehts" + ESC + "bhi" + EX + "Huiui!"
|
keys = "Wie hallo gehts" + ESC + "bhi" + EX + "Huiui!"
|
||||||
|
|
||||||
class MultilineExpandWithFormatoptionsOn_ExceptCorrectResult(_VimTest):
|
########################
|
||||||
snippets = ("test", "${1:longer expand}\n$0")
|
# Format options tests #
|
||||||
keys = "test" + EX + "This is a longer text that should wrap"
|
########################
|
||||||
wanted = "This is a longer\ntext that should\nwrap\n"
|
class _FormatoptionsBase(_VimTest):
|
||||||
def _options_on(self):
|
def _options_on(self):
|
||||||
self.send(":set tw=20\n")
|
self.send(":set tw=20\n")
|
||||||
def _options_off(self):
|
def _options_off(self):
|
||||||
self.send(":set tw=0\n")
|
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 #
|
# TabStops #
|
||||||
@ -1806,8 +1853,7 @@ class _AnonBase(_VimTest):
|
|||||||
self.send(":inoremap <silent> " + EA + ' <C-R>=UltiSnips_Anon('
|
self.send(":inoremap <silent> " + EA + ' <C-R>=UltiSnips_Anon('
|
||||||
+ self.args + ')<cr>\n')
|
+ self.args + ')<cr>\n')
|
||||||
def _options_off(self):
|
def _options_off(self):
|
||||||
self.send(":iunmap <silent> " + EA + ' <C-R>=UltiSnips_Anon('
|
self.send(":iunmap <silent> " + EA + '\n')
|
||||||
+ self.args + ')<cr>\n')
|
|
||||||
|
|
||||||
class Anon_NoTrigger_Simple(_AnonBase):
|
class Anon_NoTrigger_Simple(_AnonBase):
|
||||||
args = '"simple expand"'
|
args = '"simple expand"'
|
||||||
@ -2334,6 +2380,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
# Now, source our runtime
|
# Now, source our runtime
|
||||||
send(":so plugin/UltiSnips.vim\n", options.session)
|
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
|
# Inform all test case which screen session to use
|
||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
|
Loading…
Reference in New Issue
Block a user