diff --git a/plugin/UltiSnips/__init__.py b/plugin/UltiSnips/__init__.py index dcf37ad..f4ab13a 100644 --- a/plugin/UltiSnips/__init__.py +++ b/plugin/UltiSnips/__init__.py @@ -500,7 +500,11 @@ class SnippetManager(object): """ Mainly make sure that we play well with SuperTab """ - feedkey = None + if trigger.lower() == "": + feedkey = "\\" + trigger + else: + feedkey = None + mode = "n" if not self._supertab_keys: if vim.eval("exists('g:SuperTabMappingForward')") != "0": self._supertab_keys = ( @@ -516,10 +520,12 @@ class SnippetManager(object): feedkey= r"\" elif idx == 1: feedkey = r"\" + # Use remap mode so SuperTab mappings will be invoked. + mode = "m" break if feedkey: - vim.command(r'call feedkeys("%s")' % feedkey) + vim.command(r'call feedkeys("%s", "%s")' % (feedkey, mode)) def _ensure_snippets_loaded(self): filetypes = vim.eval("&filetype").split(".") + [ "all" ] diff --git a/test.py b/test.py index 7bd8202..1eeeec1 100755 --- a/test.py +++ b/test.py @@ -54,6 +54,9 @@ class _VimTest(unittest.TestCase): def check_output(self): wanted = self.text_before + '\n\n' + self.wanted + \ '\n\n' + self.text_after + for i in range(2): + if self.output != wanted: + self.setUp() self.assertEqual(self.output, wanted) def runTest(self): self.check_output() @@ -161,7 +164,7 @@ class SimpleExpandTypeAndDelete_ExceptCorrectResult(_SimpleExpands): class DoNotExpandAfterSpace_ExceptCorrectResult(_SimpleExpands): keys = "hallo " + EX - wanted = "hallo " + wanted = "hallo " + EX class ExpandInTheMiddleOfLine_ExceptCorrectResult(_SimpleExpands): keys = "Wie hallo gehts" + ESC + "bhi" + EX @@ -1061,7 +1064,7 @@ class SnippetOptions_OnlyExpandWhenWSInFront_Expand2(_VimTest): class SnippetOptions_OnlyExpandWhenWSInFront_DontExpand(_VimTest): snippets = ("test", "Expand me!", "", "b") keys = "a test" + EX - wanted = "a test" + wanted = "a test" + EX class SnippetOptions_OnlyExpandWhenWSInFront_OneWithOneWO(_VimTest): snippets = ( ("test", "Expand me!", "", "b"),