Make sure that decorator signature completion is working, see #1433

This commit is contained in:
Dave Halter
2019-12-03 22:18:01 +01:00
parent f46f00bc71
commit 8aee1e6213
2 changed files with 13 additions and 4 deletions

View File

@@ -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)

View File

@@ -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