Fixes Bug #691575.
Deals with the case where there are multiple matches on the line. Tries all matches until one fits!
This commit is contained in:
parent
3310ccb41d
commit
b065b5cf30
@ -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
17
test.py
@ -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 #
|
||||
#######################
|
||||
|
Loading…
Reference in New Issue
Block a user