core: Make completion item documentation optional

Path completion items always have documentation but future core (i.e.
non-LSP) completions may not always have documentation - for example
word completion from the current buffer.
pull/12778/head
Michael Davis 2025-02-01 21:24:25 -05:00
parent 369f2bb93d
commit 70d452db3e
No known key found for this signature in database
3 changed files with 6 additions and 3 deletions

View File

@ -8,7 +8,7 @@ pub struct CompletionItem {
pub label: Cow<'static, str>, pub label: Cow<'static, str>,
pub kind: Cow<'static, str>, pub kind: Cow<'static, str>,
/// Containing Markdown /// Containing Markdown
pub documentation: String, pub documentation: Option<String>,
pub provider: CompletionProvider, pub provider: CompletionProvider,
} }

View File

@ -113,7 +113,7 @@ pub(crate) fn path_completion(
kind: Cow::Borrowed(kind), kind: Cow::Borrowed(kind),
label: file_name.into(), label: file_name.into(),
transaction, transaction,
documentation, documentation: Some(documentation),
provider: CompletionProvider::Path, provider: CompletionProvider::Path,
})) }))
}) })

View File

@ -523,7 +523,10 @@ impl Component for Completion {
None => return, None => return,
}, },
CompletionItem::Other(option) => { CompletionItem::Other(option) => {
markdowned(language, None, Some(&option.documentation)) let Some(doc) = option.documentation.as_deref() else {
return;
};
markdowned(language, None, Some(doc))
} }
}; };