From 461e81d6a2ffed4a6082ede80881ed9c7b9da3ac Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Sun, 20 Feb 2011 20:49:32 +0100 Subject: [PATCH] Added stricter test case that show the problem and implement fixes for them --- plugin/UltiSnips/__init__.py | 4 ++-- test.py | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/plugin/UltiSnips/__init__.py b/plugin/UltiSnips/__init__.py index 9b98c27..fdc9dc9 100644 --- a/plugin/UltiSnips/__init__.py +++ b/plugin/UltiSnips/__init__.py @@ -694,8 +694,8 @@ 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) + self._backspace(self._vstate.ppos.col-len(lline)) + self._chars_entered('\n' + cline[:len(cline)-(len(self._vstate.last_line)-self._vstate.ppos.col)], 1) else: pentered = lline[self._vstate.ppos.col:] this_entered = vim.current.line[:self._vstate.pos.col] diff --git a/test.py b/test.py index a650c4a..60720bb 100755 --- a/test.py +++ b/test.py @@ -226,6 +226,43 @@ class MultilineExpandWithFormatoptionsOn_ExceptCorrectResult(_VimTest): def _options_off(self): self.send(":set tw=0\n") +class MultilineExpandWithFormatoptionsOnTextAfter_ExceptCorrectResult(_VimTest): + """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""" + def _options_on(self): + self.send(":set tw=20\n") + def _options_off(self): + self.send(":set tw=0\n") + +class MultilineExpandWithFormatoptionsWrapOnLongWord_ExceptCorrectResult(_VimTest): + """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""" + + def _options_on(self): + self.send(":set tw=20\n") + def _options_off(self): + self.send(":set tw=0\n") ############ # TabStops #