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
|
""" Test if a the current regex trigger matches
|
||||||
`trigger`. If so, set _last_re and _matched.
|
`trigger`. If so, set _last_re and _matched.
|
||||||
"""
|
"""
|
||||||
match = re.search(self._t, trigger)
|
for match in re.finditer(self._t, trigger):
|
||||||
if match:
|
|
||||||
if match.end() != len(trigger):
|
if match.end() != len(trigger):
|
||||||
match = False
|
continue
|
||||||
else:
|
else:
|
||||||
self._matched = trigger[match.start():match.end()]
|
self._matched = trigger[match.start():match.end()]
|
||||||
if match:
|
|
||||||
self._last_re = match
|
self._last_re = match
|
||||||
else:
|
return match
|
||||||
self._last_re = None
|
return False
|
||||||
return match
|
|
||||||
|
|
||||||
def matches(self, trigger):
|
def matches(self, trigger):
|
||||||
# If user supplies both "w" and "i", it should perhaps be an
|
# 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
|
keys = "test cabfed" + EX
|
||||||
wanted = "test No match"
|
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 #
|
# MULTI-WORD SNIPPETS #
|
||||||
#######################
|
#######################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user