Fixed problem with tab being ignored on failed snippet expansion.

This commit is contained in:
Michael Henry 2009-08-24 06:28:54 -04:00
parent 4721cb0a9b
commit 9a19e9c573
2 changed files with 13 additions and 4 deletions

View File

@ -500,7 +500,11 @@ class SnippetManager(object):
""" """
Mainly make sure that we play well with SuperTab Mainly make sure that we play well with SuperTab
""" """
if trigger.lower() == "<tab>":
feedkey = "\\" + trigger
else:
feedkey = None feedkey = None
mode = "n"
if not self._supertab_keys: if not self._supertab_keys:
if vim.eval("exists('g:SuperTabMappingForward')") != "0": if vim.eval("exists('g:SuperTabMappingForward')") != "0":
self._supertab_keys = ( self._supertab_keys = (
@ -516,10 +520,12 @@ class SnippetManager(object):
feedkey= r"\<c-n>" feedkey= r"\<c-n>"
elif idx == 1: elif idx == 1:
feedkey = r"\<c-p>" feedkey = r"\<c-p>"
# Use remap mode so SuperTab mappings will be invoked.
mode = "m"
break break
if feedkey: if feedkey:
vim.command(r'call feedkeys("%s")' % feedkey) vim.command(r'call feedkeys("%s", "%s")' % (feedkey, mode))
def _ensure_snippets_loaded(self): def _ensure_snippets_loaded(self):
filetypes = vim.eval("&filetype").split(".") + [ "all" ] filetypes = vim.eval("&filetype").split(".") + [ "all" ]

View File

@ -54,6 +54,9 @@ class _VimTest(unittest.TestCase):
def check_output(self): def check_output(self):
wanted = self.text_before + '\n\n' + self.wanted + \ wanted = self.text_before + '\n\n' + self.wanted + \
'\n\n' + self.text_after '\n\n' + self.text_after
for i in range(2):
if self.output != wanted:
self.setUp()
self.assertEqual(self.output, wanted) self.assertEqual(self.output, wanted)
def runTest(self): self.check_output() def runTest(self): self.check_output()
@ -161,7 +164,7 @@ class SimpleExpandTypeAndDelete_ExceptCorrectResult(_SimpleExpands):
class DoNotExpandAfterSpace_ExceptCorrectResult(_SimpleExpands): class DoNotExpandAfterSpace_ExceptCorrectResult(_SimpleExpands):
keys = "hallo " + EX keys = "hallo " + EX
wanted = "hallo " wanted = "hallo " + EX
class ExpandInTheMiddleOfLine_ExceptCorrectResult(_SimpleExpands): class ExpandInTheMiddleOfLine_ExceptCorrectResult(_SimpleExpands):
keys = "Wie hallo gehts" + ESC + "bhi" + EX keys = "Wie hallo gehts" + ESC + "bhi" + EX
@ -1061,7 +1064,7 @@ class SnippetOptions_OnlyExpandWhenWSInFront_Expand2(_VimTest):
class SnippetOptions_OnlyExpandWhenWSInFront_DontExpand(_VimTest): class SnippetOptions_OnlyExpandWhenWSInFront_DontExpand(_VimTest):
snippets = ("test", "Expand me!", "", "b") snippets = ("test", "Expand me!", "", "b")
keys = "a test" + EX keys = "a test" + EX
wanted = "a test" wanted = "a test" + EX
class SnippetOptions_OnlyExpandWhenWSInFront_OneWithOneWO(_VimTest): class SnippetOptions_OnlyExpandWhenWSInFront_OneWithOneWO(_VimTest):
snippets = ( snippets = (
("test", "Expand me!", "", "b"), ("test", "Expand me!", "", "b"),