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 completion item label condition #584

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

soywod
Copy link

@soywod soywod commented Dec 30, 2024

Related to #583.

When fuzzy completion is used, the wrong label is used when validating a completion item. For example, rust-analyzer could return remove_dir (alias rmdir) as a label, but remove_dir as next text (this late one should be used instead of the first one).

I'm not sure to understand why this section is restricted to non-fuzzy completion value matcher only. The label condition (either item.textEdit.newText, item.insertText or item.label) is useful no matter the completion matcher.

@berggeist
Copy link
Contributor

I don't know why fuzzy matching is excluded here.
I would guess that text editing by applying the range does not play well in combination with fuzzy matching. But this is only a guess.
By the way, it has been introduced by @andlrc with his pull request: #178
Maybe @andlrc can enlighten us here.

Instead of removing the special handling of fuzzy matching, an additonal fallback branch might also help. Otherwise the language server specifiation is not fulfilled, which mandates CompletionItem.label shall only be used if there is neither CompletionItem.insertText nor CompletionItem.textEdit.

    if item->has_key('textEdit') &&
	lspOpts.completionMatcherValue != opt.COMPLETIONMATCHER_FUZZY

...
new fallback branch:

    elseif item->has_key('textEdit')
       d.word = item.textEdit.newText
    elseif item->has_key('insertText')
      d.word = item.insertText
    else
      d.word = item.label
    endif

@soywod
Copy link
Author

soywod commented Jan 1, 2025

elseif item->has_key('textEdit') would still prevent fuzzy completion to get the right label. Let's wait for more context about the condition.

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.

2 participants