@@ -295,6 +295,27 @@ impl Completion {
295295 pub fn is_empty(&self) -> bool {
296296 self.popup.contents().is_empty()
297297 }
298+
299+ pub fn ensure_item_resolved(&mut self, cx: &mut commands::Context) -> bool {
300+ // > If computing full completion items is expensive, servers can additionally provide a
301+ // > handler for the completion item resolve request. ...
302+ // > A typical use case is for example: the `textDocument/completion` request doesn't fill
303+ // > in the `documentation` property for returned completion items since it is expensive
304+ // > to compute. When the item is selected in the user interface then a
305+ // > 'completionItem/resolve' request is sent with the selected completion item as a parameter.
306+ // > The returned completion item should have the documentation property filled in.
307+ // https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion
308+ match self.popup.contents_mut().selection_mut() {
309+ Some(item) if item.documentation.is_none() => {
310+ let doc = doc!(cx.editor);
311+ if let Some(resolved_item) = Self::resolve_completion_item(doc, item.clone()) {
312+ *item = resolved_item;
313+ }
314+ true
315+ }
316+ _ => false,
317+ }
318+ }
298319}
299320
300321impl Component for Completion {