forked from VimPlug/jedi
Avoid wrong random call signature completion, fixes #1433
This commit is contained in:
@@ -210,7 +210,15 @@ class Completion:
|
||||
completion_names += self._global_completions()
|
||||
completion_names += self._get_class_value_completions(is_function=False)
|
||||
|
||||
if 'trailer' in nonterminals:
|
||||
# Apparently this looks like it's good enough to filter most cases
|
||||
# so that signature completions don't randomly appear.
|
||||
# To understand why this works, two things are important:
|
||||
# 1. trailer with a `,` in it is either a subscript or an arglist.
|
||||
# 2. If there's no `,`, it's at the start and only signatures start
|
||||
# with `(`. Other trailers could start with `.` or `[`.
|
||||
# One thing that might not work is completion in decorator
|
||||
# executions, but most people won't care about that.
|
||||
if nodes[-1] in ['(', ','] and nonterminals[-1] in ('trailer', 'arglist'):
|
||||
call_signatures = self._call_signatures_callback()
|
||||
completion_names += get_call_signature_param_names(call_signatures)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from jedi._compatibility import unicode
|
||||
from jedi.inference.compiled.value import CompiledObject, CompiledName, \
|
||||
CompiledObjectFilter, CompiledValueName, create_from_access_path
|
||||
from jedi.inference.base_value import ValueWrapper, LazyValueWrapper
|
||||
from jedi.inference.base_value import LazyValueWrapper
|
||||
|
||||
|
||||
def builtin_from_name(inference_state, string):
|
||||
|
||||
@@ -60,3 +60,23 @@ Test().test(blub=)
|
||||
|
||||
#? 12 []
|
||||
any(iterable=)
|
||||
|
||||
|
||||
def foo(xyz):
|
||||
pass
|
||||
|
||||
#? 7 ['xyz']
|
||||
foo(xyz)
|
||||
# No completion should be possible if it's not a simple name
|
||||
#? 17 []
|
||||
x = " "; foo(x.xyz)
|
||||
#? 17 []
|
||||
x = " "; foo([xyz)
|
||||
#? 20 []
|
||||
x = " "; foo(z[f,xyz)
|
||||
#? 18 []
|
||||
x = " "; foo(z[xyz)
|
||||
#? 20 []
|
||||
x = " "; foo(xyz[xyz)
|
||||
#? 20 []
|
||||
x = " "; foo(xyz[(xyz)
|
||||
|
||||
Reference in New Issue
Block a user