Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly choose which parameter is active in signature help #1610

Open
jakebailey opened this issue Oct 1, 2019 · 1 comment

Comments

@jakebailey
Copy link
Member

commented Oct 1, 2019

Our code in the signature source to pick which parameter is active is just:

var index = location.ToIndex(analysis.Ast);
if (call.GetArgumentAtIndex(analysis.Ast, index, out var activeParameter) && activeParameter < 0) {
	// Returned 'true' and activeParameter == -1 means that we are after 
	// the trailing comma, so assume partially typed expression such as 'pow(x, y, |)
	activeParameter = call.Args.Count;
}

Which is basically just "count the number of arguments at the call site then use that as the parameter number". But this definitely doesn't work when *args or **kwargs are present.

If I have:

def func(a, b, *args, **kwargs): ...

And write func(1, 2, 3, 4, 5, 6, 7, 8, etc), after 2 I should stay in the args argument, as that is where the parameters are going.

This might take extracting some ArgumentSet logic out into a common place, or even constructing an ArgumentSet at the signature help request and then reading info back out of it.

@jakebailey

This comment has been minimized.

Copy link
Member Author

commented Oct 1, 2019

#401 related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.