Skip to content

x/tools/gopls: improve completion for variadic params #34334

Closed
@muirdm

Description

@muirdm

In cases like this:

foo := func(...string) {}
var myStr string
foo("hi", <>)

we should prefer "myStr" since we know we are completing an individual string.

Also, we should add "..." to variadic completion items:

foo := func(...string) {}
var myStrs []string
foo(mySt<>) // complete to "myStrs..." instead of just "myStrs"

Consider whether we should do it for cases like this:

foo := func(...interface{}) {}
var myIntf []interface{}
foo(myIn<>) // should this complete to "myIntf..." or just "myIntf"?

Personally I think it should still expand in this case to myIntf... because that is more likely what you want vs passing the []interface{} as the first variadic interface{}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions