fix tests
This commit is contained in:
parent
b3aec07053
commit
ed8cf49115
@ -44,7 +44,7 @@ class SnippetDefinition(object):
|
||||
_TABS = re.compile(r"^\t*")
|
||||
|
||||
def __init__(self, priority, trigger, value, description,
|
||||
options, globals, location, context):
|
||||
options, globals, location, context=None):
|
||||
self._priority = int(priority)
|
||||
self._trigger = as_unicode(trigger)
|
||||
self._value = as_unicode(value)
|
||||
|
@ -79,7 +79,6 @@ def _handle_snippet_or_global(filename, line, lines, python_globals, priority):
|
||||
else:
|
||||
context = None
|
||||
|
||||
|
||||
# Get and strip description if it exists
|
||||
remain = remain.strip()
|
||||
if len(remain.split()) > 1 and remain[-1] == '"':
|
||||
|
@ -203,18 +203,19 @@ class SnippetManager(object):
|
||||
|
||||
@err_to_scratch_buffer
|
||||
def add_snippet(self, trigger, value, description,
|
||||
options, ft='all', priority=0):
|
||||
options, ft='all', priority=0, context=None):
|
||||
"""Add a snippet to the list of known snippets of the given 'ft'."""
|
||||
self._added_snippets_source.add_snippet(ft,
|
||||
UltiSnipsSnippetDefinition(priority, trigger, value,
|
||||
description, options, {}, 'added'))
|
||||
description, options, {}, 'added',
|
||||
context))
|
||||
|
||||
@err_to_scratch_buffer
|
||||
def expand_anon(self, value, trigger='', description='', options=''):
|
||||
def expand_anon(self, value, trigger='', description='', options='', context=None):
|
||||
"""Expand an anonymous snippet right here."""
|
||||
before = _vim.buf.line_till_cursor
|
||||
snip = UltiSnipsSnippetDefinition(0, trigger, value, description,
|
||||
options, {}, '')
|
||||
options, {}, '', context)
|
||||
|
||||
if not trigger or snip.matches(before):
|
||||
self._do_snippet(snip, before)
|
||||
@ -573,10 +574,11 @@ class SnippetManager(object):
|
||||
if not before:
|
||||
return False
|
||||
snippets = self._snips(before, False)
|
||||
# prefer snippets with context if any
|
||||
snippets_with_context = [s for s in snippets if s.context]
|
||||
if snippets_with_context:
|
||||
snippets = snippets_with_context
|
||||
if snippets:
|
||||
# prefer snippets with context if any
|
||||
snippets_with_context = [s for s in snippets if s.context]
|
||||
if snippets_with_context:
|
||||
snippets = snippets_with_context
|
||||
if not snippets:
|
||||
# No snippet found
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user