Skip to content

Commit

Permalink
LSP: Resolve completion items when additional text edits are empty
Browse files Browse the repository at this point in the history
Rust-analyzer for example sends `Some([])` for completion items and then
sends the actual additional text edits in the completionItem/resolve
response.
  • Loading branch information
the-mikedavis committed Jun 3, 2024
1 parent 6dbab51 commit fe3b99f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion helix-term/src/handlers/completion/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,17 @@ impl ResolveHandler {
if item.resolved {
return;
}
// We resolve items when docs or details are missing or when the additional text edits
// are either `None` or `Some([])`. The spec is not totally explicit on the conditions
// for this and needing to resolve when the additional text edits are `Some([])` is
// probably a consequence of how null works in the JavaScript world.
let needs_resolve = item.item.documentation.is_none()
|| item.item.detail.is_none()
|| item.item.additional_text_edits.is_none();
|| !item
.item
.additional_text_edits
.as_ref()
.is_some_and(|edits| !edits.is_empty());
if !needs_resolve {
item.resolved = true;
return;
Expand Down

0 comments on commit fe3b99f

Please sign in to comment.