diff --git a/jedi/api/completion.py b/jedi/api/completion.py index 75ce10e1..0876ac35 100644 --- a/jedi/api/completion.py +++ b/jedi/api/completion.py @@ -212,13 +212,13 @@ class Completion: # 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: + # To understand why this works, three 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'): + # 3. Decorators are very primitive and have an optional `(` with + # optional arglist in them. + if nodes[-1] in ['(', ','] and nonterminals[-1] in ('trailer', 'arglist', 'decorator'): call_signatures = self._call_signatures_callback() completion_names += get_call_signature_param_names(call_signatures) diff --git a/test/completion/named_param.py b/test/completion/named_param.py index 3bd27ece..024e2bfb 100644 --- a/test/completion/named_param.py +++ b/test/completion/named_param.py @@ -80,3 +80,12 @@ x = " "; foo(z[xyz) x = " "; foo(xyz[xyz) #? 20 [] x = " "; foo(xyz[(xyz) + +#? 8 ['xyz'] +@foo(xyz) +def x(): pass + +@str +#? 8 ['xyz'] +@foo(xyz) +def x(): pass