From bdecd9a8b5ebbc65e8929a5e14133021415c2f22 Mon Sep 17 00:00:00 2001 From: Stanislav Seletskiy Date: Thu, 9 Jul 2015 17:26:56 +0600 Subject: [PATCH] fix not cleared context --- pythonx/UltiSnips/snippet/definition/_base.py | 1 + test/test_ContextSnippets.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/pythonx/UltiSnips/snippet/definition/_base.py b/pythonx/UltiSnips/snippet/definition/_base.py index 5757bb0..c6b0f62 100644 --- a/pythonx/UltiSnips/snippet/definition/_base.py +++ b/pythonx/UltiSnips/snippet/definition/_base.py @@ -242,6 +242,7 @@ class SnippetDefinition(object): self._matched = '' return False + self._context = None if match and self._context_code: self._context = self._context_match() if not self.context: diff --git a/test/test_ContextSnippets.py b/test/test_ContextSnippets.py index 69d07b9..f178b40 100644 --- a/test/test_ContextSnippets.py +++ b/test/test_ContextSnippets.py @@ -138,3 +138,14 @@ class ContextSnippets_CursorIsZeroBased(_VimTest): keys = "e" + EX wanted = "(2, 1)" + +class ContextSnippets_ContextIsClearedBeforeExpand(_VimTest): + files = { 'us/all.snippets': r""" + pre_expand "snip.context = 1 if snip.context is None else 2" + snippet e "desc" w + `!p snip.rv = str(snip.context)` + endsnippet + """} + + keys = "e" + EX + " " + "e" + EX + wanted = "1 1"