Deals with the case where there are multiple matches on the line. Tries all
matches until one fits!
This commit is contained in:
rygwdn@gmail.com 2010-12-17 22:38:56 -04:00
parent 3310ccb41d
commit b065b5cf30
2 changed files with 22 additions and 7 deletions

View File

@ -234,17 +234,15 @@ class Snippet(object):
""" Test if a the current regex trigger matches
`trigger`. If so, set _last_re and _matched.
"""
match = re.search(self._t, trigger)
if match:
for match in re.finditer(self._t, trigger):
if match.end() != len(trigger):
match = False
continue
else:
self._matched = trigger[match.start():match.end()]
if match:
self._last_re = match
else:
self._last_re = None
return match
return match
return False
def matches(self, trigger):
# If user supplies both "w" and "i", it should perhaps be an

17
test.py
View File

@ -1550,6 +1550,23 @@ class SnippetOptions_Regex_PythonBlockNoMatch(_VimTest):
keys = "test cabfed" + EX
wanted = "test No match"
# Tests for Bug #691575
class SnippetOptions_Regex_SameLine_Long_End(_VimTest):
snippets = ("(test.*)", "Expand me!", "", "r")
keys = "test test abc" + EX
wanted = "Expand me!"
class SnippetOptions_Regex_SameLine_Long_Start(_VimTest):
snippets = ("(.*test)", "Expand me!", "", "r")
keys = "abc test test" + EX
wanted = "Expand me!"
class SnippetOptions_Regex_SameLine_Simple(_VimTest):
snippets = ("(test)", "Expand me!", "", "r")
keys = "abc test test" + EX
wanted = "abc test Expand me!"
#######################
# MULTI-WORD SNIPPETS #
#######################