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

LSP: Resolve completion items when any info is missing #10873

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions helix-term/src/handlers/completion/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,30 @@ impl ResolveHandler {
if item.resolved {
return;
}
let needs_resolve = item.item.documentation.is_none()
|| item.item.detail.is_none()
|| item.item.additional_text_edits.is_none();
if !needs_resolve {
// We consider an item to be fully resolved if it has non-empty, none-`None` details,
Copy link
Contributor

Choose a reason for hiding this comment

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

is none- supposed to be non-? Or is this implying something else?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep that's a typo, should be "non-None"

// docs and additional text-edits. Ideally we could use `is_some` instead of this
// check but some language servers send values like `Some([])` for additional text
// edits although the items need to be resolved. This is probably a consequence of
// how `null` works in the JavaScript world.
let is_resolved = item
.item
.documentation
.as_ref()
.is_some_and(|docs| match docs {
lsp::Documentation::String(text) => !text.is_empty(),
lsp::Documentation::MarkupContent(markup) => !markup.value.is_empty(),
})
&& item
.item
.detail
.as_ref()
.is_some_and(|detail| !detail.is_empty())
&& item
.item
.additional_text_edits
.as_ref()
.is_some_and(|edits| !edits.is_empty());
if is_resolved {
item.resolved = true;
return;
}
Expand Down
Loading