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"