From a514585cde2aa072a8f061380a8a794123b29ce0 Mon Sep 17 00:00:00 2001 From: Stanislav Seletskiy Date: Mon, 28 Mar 2016 12:21:07 +0600 Subject: [PATCH 1/2] ignore .ropeproject --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bb169b4..2584ce0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.pyc *.swp doc/tags +.ropeproject/ From 7536ac9002fb3698a9db4b819706de880d0ca724 Mon Sep 17 00:00:00 2001 From: Stanislav Seletskiy Date: Mon, 28 Mar 2016 12:21:09 +0600 Subject: [PATCH 2/2] tabstops can be overwritten from interpolation It adds new type of flexibility, where just entered text can be dynamically modified if some conditions are satisfied (e.g. dynamically add line wraps). --- pythonx/UltiSnips/text_objects/_python_code.py | 8 ++++++++ test/test_Interpolation.py | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/pythonx/UltiSnips/text_objects/_python_code.py b/pythonx/UltiSnips/text_objects/_python_code.py index dac036e..e2a1459 100644 --- a/pythonx/UltiSnips/text_objects/_python_code.py +++ b/pythonx/UltiSnips/text_objects/_python_code.py @@ -28,6 +28,14 @@ class _Tabs(object): return '' return ts.current_text + def __setitem__(self, no, value): + ts = self._to._get_tabstop( + self._to, + int(no)) # pylint:disable=protected-access + if ts is None: + return + ts.overwrite(value) + _VisualContent = namedtuple('_VisualContent', ['mode', 'text']) diff --git a/test/test_Interpolation.py b/test/test_Interpolation.py index b006355..e8e8bae 100644 --- a/test/test_Interpolation.py +++ b/test/test_Interpolation.py @@ -429,6 +429,17 @@ class PythonCode_AccessKilledTabstop_OverwriteFirst(_VimTest): keys = 'test' + EX + 'aaa' wanted = 'aaa' +class PythonCode_CanOverwriteTabstop(_VimTest): + snippets = ( + 'test', + """$1`!p if len(t[1]) > 3 and len(t[2]) == 0: + t[2] = t[1][2:]; + t[1] = t[1][:2] + '-\\n\\t'; + vim.command('call feedkeys("\", "n")'); + `$2""") + keys = 'test' + EX + 'blah' + ', bah' + wanted = "bl-\n\tah, bah" + class PythonVisual_NoVisualSelection_Ignore(_VimTest): snippets = ('test', 'h`!p snip.rv = snip.v.mode + snip.v.text`b')