From 5340bb174e6d937f2b3918526de28fcbaef351e6 Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Sat, 21 Aug 2010 12:06:03 +0200 Subject: [PATCH 1/2] New failing tests --- test.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test.py b/test.py index 4af4902..d49ec87 100755 --- a/test.py +++ b/test.py @@ -1933,6 +1933,39 @@ xj k """ +class _MultiLineDefault(_VimTest): + snippets = ("test", r""" +x${1:a +b +c +d +e +f} +$2""") + +class MultiLineDefault_Jump(_MultiLineDefault): + keys = "test" + EX + JF + "y" + wanted = """ +xa +b +c +d +e +f +y""" + +class MultiLineDefault_Type(_MultiLineDefault): + keys = "test" + EX + "z" + JF + "y" + wanted = """ +xz +y""" + +class MultiLineDefault_BS(_MultiLineDefault): + keys = "test" + EX + BS + JF + "y" + wanted = """ +x +y""" + ####################### # Test for bug 427298 # ####################### From 09939c2921c70b18b47406a3e690bdcd75e7f059 Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Sat, 21 Aug 2010 13:07:54 +0200 Subject: [PATCH 2/2] Fixed the bug again --- plugin/UltiSnips/__init__.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugin/UltiSnips/__init__.py b/plugin/UltiSnips/__init__.py index 3a247dd..155bf91 100644 --- a/plugin/UltiSnips/__init__.py +++ b/plugin/UltiSnips/__init__.py @@ -671,7 +671,9 @@ class SnippetManager(object): # BS was called in select mode if self._cs and (self._span_selected is not None): - # This only happens when a default value is delted using backspace + # This only happens when a default value is delted using backspace. + # This does not change the buffer at all, only moves the cursor. + self._vstate.update() feedkeys(r"i") self._chars_entered('') else: @@ -958,8 +960,13 @@ class SnippetManager(object): if (self._span_selected is not None): self._ctab.current_text = chars - moved = self._span_selected.start.line - \ - self._span_selected.end.line + moved = 0 + # Compensate if this edit changed the buffer in any ways: we might + # have to delete more or less lines, according how the cursors has + # moved + if self._vstate.buf_changed: + moved = self._span_selected.start.line - \ + self._span_selected.end.line self._span_selected = None self._update_vim_buffer(moved + del_more_lines) @@ -983,7 +990,9 @@ class SnippetManager(object): s.update() # Replace - dlines += self._vstate.moved.line + del_more_lines + if self._vstate.buf_changed: + dlines += self._vstate.moved.line + dlines += del_more_lines self._vb.replace_lines(sline, sline + dlines, s._current_text) ct_end = self._ctab.abs_end