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

x/tools/gopls: order struct fields completions by definition #42626

Closed
golopot opened this issue Nov 16, 2020 · 1 comment
Closed

x/tools/gopls: order struct fields completions by definition #42626

golopot opened this issue Nov 16, 2020 · 1 comment

Comments

@golopot
Copy link

@golopot golopot commented Nov 16, 2020

When I am writing a struct literal, I expect the completion suggestions to be ordered the same way as when it is defined. For example, if a struct has 4 fields, in order, key, content, start, end, I expect the the completion suggestions to be be ordered just like that, instead of alphabetically, like content, end, key, start.

Developers usually order fields purposefully, both in definition and struct literal. For example is it unnatural to write end before start, and it is conventional to put key as the first field. Therefore changing the suggestion order will make completion more ergonomic.

Example:

type Foo struct {
        key string
        content string
        start string
	end string
}

func main() {
	foo := Foo{
        <>
        // expects the first suggestion to be `key`
        // but got `content` instead 
	}
}
@gopherbot gopherbot added this to the Unreleased milestone Nov 16, 2020
@golopot golopot changed the title x/tools/gopls: completion suggestions for struct literal fields should be ordered by definition x/tools/gopls: order struct fields completions by definition Nov 16, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Nov 17, 2020

Change https://golang.org/cl/270777 mentions this issue: internal/lsp: order struct fields completions by definition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.