Merge branch 'guns-vim-word-boundaries'

This commit is contained in:
Holger Rapp 2013-12-24 11:31:48 +01:00
commit d7a4f82bc1
2 changed files with 5 additions and 3 deletions

View File

@ -612,7 +612,7 @@ The options currently supported are: >
the tab trigger start matches a word boundary and the tab trigger end the tab trigger start matches a word boundary and the tab trigger end
matches a word boundary. In other words the tab trigger must be matches a word boundary. In other words the tab trigger must be
preceded and followed by non-word characters. Word characters are preceded and followed by non-word characters. Word characters are
letters, digits and the underscore. Use this option, for example, to defined by the 'iskeyword' setting. Use this option, for example, to
permit expansion where the tab trigger follows punctuation without permit expansion where the tab trigger follows punctuation without
expanding suffixes of larger words. expanding suffixes of larger words.

View File

@ -315,7 +315,8 @@ class Snippet(object):
if match and words_prefix: if match and words_prefix:
# Require a word boundary between prefix and suffix. # Require a word boundary between prefix and suffix.
boundaryChars = words_prefix[-1:] + words_suffix[:1] boundaryChars = words_prefix[-1:] + words_suffix[:1]
match = re.match(r'.\b.', boundaryChars) boundaryChars = boundaryChars.replace('"', '\\"')
match = _vim.eval('"%s" =~# "\\\\v.<."' % boundaryChars) != '0'
elif "i" in self._opts: elif "i" in self._opts:
match = words.endswith(self._t) match = words.endswith(self._t)
else: else:
@ -350,7 +351,8 @@ class Snippet(object):
match = self._re_match(trigger) match = self._re_match(trigger)
elif "w" in self._opts: elif "w" in self._opts:
# Trim non-empty prefix up to word boundary, if present. # Trim non-empty prefix up to word boundary, if present.
words_suffix = re.sub(r'^.+\b(.+)$', r'\1', words) qwords = words.replace('"', '\\"')
words_suffix = _vim.eval('substitute("%s", "\\\\v^.+<(.+)", "\\\\1", "")' % qwords)
match = self._t.startswith(words_suffix) match = self._t.startswith(words_suffix)
self._matched = words_suffix self._matched = words_suffix