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

Fix issue with completing idents in the language server #2917

Merged
merged 2 commits into from
Nov 1, 2023

Conversation

Tatskaari
Copy link
Member

Not totally confident this is 100% correct but in my testing, this resolves the issue.

Fixes: #2906

@Tatskaari Tatskaari force-pushed the fix-ident-completion branch from 7565012 to 448e73b Compare October 9, 2023 11:39
@@ -111,7 +111,7 @@ func (h *Handler) completeIdent(doc *doc, s string, line, col int) (*lsp.Complet
list := &lsp.CompletionList{}
for name, f := range h.builtins {
if strings.HasPrefix(name, s) {
item := completionItem(name, s, line, col)
item := completionItem(name, "", line, col)
Copy link
Member Author

@Tatskaari Tatskaari Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're completing "check_" to "check_config", name would be "check_config", and s would have been "check_". We would then produce a replacement from "check_" to "config", rather than to the full "check_config" because we strip this prefix. I think this prefix is for when we complete labels within a package. We would have a list of completions with just the target name, and the prefix would be the //foo: bit.

The prefix would be //foo: but the completion list would contain just the label name, i.e. "bar" (as opposed to "//foo:bar". We then produce an edit for the column after the : to insert just the name rather than replacing the full label. This is not the case for idents though. I have tested completing member functions too, and they work just fine.

Copy link
Collaborator

@peterebden peterebden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit stale on the LSP but this seems correct. Thanks!

@Tatskaari Tatskaari changed the title Fix issue with complleting idents in the language server Fix issue with completing idents in the language server Nov 1, 2023
@Tatskaari Tatskaari merged commit fe0b151 into thought-machine:master Nov 1, 2023
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please LSP's autocompletion lost first character when inserting into neovim buffers
3 participants