mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
LSP: Resolve completion items when any info is missing (#10873)
This commit is contained in:
parent
c39cde8fc2
commit
6f1437e9f3
@ -42,10 +42,30 @@ pub fn ensure_item_resolved(&mut self, editor: &mut Editor, item: &mut Completio
|
|||||||
if item.resolved {
|
if item.resolved {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let needs_resolve = item.item.documentation.is_none()
|
// We consider an item to be fully resolved if it has non-empty, none-`None` details,
|
||||||
|| item.item.detail.is_none()
|
// docs and additional text-edits. Ideally we could use `is_some` instead of this
|
||||||
|| item.item.additional_text_edits.is_none();
|
// check but some language servers send values like `Some([])` for additional text
|
||||||
if !needs_resolve {
|
// 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;
|
item.resolved = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user