keyword completion shouldn't occur all the times; thanks to Tobias Halter for his brilliant Kantischueler logic.

This commit is contained in:
David Halter
2012-09-30 16:46:28 +02:00
parent 511369ad88
commit ff84e4670b
2 changed files with 10 additions and 5 deletions

View File

@@ -185,8 +185,9 @@ class Script(object):
path, dot, like = self._get_completion_parts(path) path, dot, like = self._get_completion_parts(path)
try: try:
scopes = self._prepare_goto(path, True) scopes = list(self._prepare_goto(path, True))
except NotFoundError: except NotFoundError:
scopes = []
scope_generator = evaluate.get_names_for_scope( scope_generator = evaluate.get_names_for_scope(
self.parser.user_scope, self.pos) self.parser.user_scope, self.pos)
completions = [] completions = []
@@ -214,9 +215,13 @@ class Script(object):
for p in call_def.params: for p in call_def.params:
completions.append((p.get_name(), p)) completions.append((p.get_name(), p))
# add keywords # Do the completion if there is no path before and no import stmt.
s = builtin.builtin_scope if (not scopes or not isinstance(scopes[0], imports.ImportPath)) \
completions += ((k, s) for k in keywords.get_keywords(all=True)) and not path:
# add keywords
bs = builtin.builtin_scope
completions += ((k, bs) for k in keywords.get_keywords(
all=True))
completions = [(c, s) for c, s in completions completions = [(c, s) for c, s in completions
if settings.case_insensitive_completion if settings.case_insensitive_completion

View File

@@ -50,7 +50,7 @@ class TestClass(object):
# should not know any class functions! # should not know any class functions!
#? [] #? []
values values
#? [] #? ['return']
ret ret
return a1 return a1