1
0
forked from VimPlug/jedi

ignore duplicates of completion outputs, #97

This commit is contained in:
David Halter
2012-12-29 01:59:34 +01:00
parent b04e74ca7d
commit 406233b62d
3 changed files with 15 additions and 1 deletions

View File

@@ -146,6 +146,7 @@ class Script(object):
needs_dot = not dot and path needs_dot = not dot and path
comps = [] comps = []
comp_dct = {}
for c, s in set(completions): for c, s in set(completions):
n = c.names[-1] n = c.names[-1]
if settings.case_insensitive_completion \ if settings.case_insensitive_completion \
@@ -155,7 +156,12 @@ class Script(object):
self._parser.user_stmt, n): self._parser.user_stmt, n):
new = api_classes.Completion(c, needs_dot, new = api_classes.Completion(c, needs_dot,
len(like), s) len(like), s)
comps.append(new) n = new.complete
if n in comp_dct and not settings.no_completion_duplicates:
comp_dct[n].same_name_completions.append(new)
else:
comp_dct[n] = new
comps.append(new)
debug.speed('complete end') debug.speed('complete end')

View File

@@ -163,6 +163,10 @@ class Completion(BaseDefinition):
self.like_name_length = like_name_length self.like_name_length = like_name_length
self.base = base self.base = base
# Completion objects with the same Completion name (which means
# duplicate items in the completion)
self.same_name_completions = []
self._followed_definitions = None self._followed_definitions = None
@property @property

View File

@@ -14,6 +14,10 @@ add_dot_after_module = False
# Removed it again, because in VIM that is not very practical. # Removed it again, because in VIM that is not very practical.
add_bracket_after_function = False add_bracket_after_function = False
# If set, completions with the same name don't appear in the output anymore,
# but are in the `same_name_completions` attribute.
no_completion_duplicates = False
# ---------------- # ----------------
# parser # parser
# ---------------- # ----------------