Unnamed repository; edit this file 'description' to name the repository.
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.
Michael Davis 2025-02-02
parent 369f2bb · commit 70d452d
-rw-r--r--helix-core/src/completion.rs2
-rw-r--r--helix-term/src/handlers/completion/path.rs2
-rw-r--r--helix-term/src/ui/completion.rs5
3 files changed, 6 insertions, 3 deletions
diff --git a/helix-core/src/completion.rs b/helix-core/src/completion.rs
index c13b440c..29c86b73 100644
--- a/helix-core/src/completion.rs
+++ b/helix-core/src/completion.rs
@@ -8,7 +8,7 @@ pub struct CompletionItem {
pub label: Cow<'static, str>,
pub kind: Cow<'static, str>,
/// Containing Markdown
- pub documentation: String,
+ pub documentation: Option<String>,
pub provider: CompletionProvider,
}
diff --git a/helix-term/src/handlers/completion/path.rs b/helix-term/src/handlers/completion/path.rs
index 21dc9c31..c2ffa5ef 100644
--- a/helix-term/src/handlers/completion/path.rs
+++ b/helix-term/src/handlers/completion/path.rs
@@ -113,7 +113,7 @@ pub(crate) fn path_completion(
kind: Cow::Borrowed(kind),
label: file_name.into(),
transaction,
- documentation,
+ documentation: Some(documentation),
provider: CompletionProvider::Path,
}))
})
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index be78dd08..e17762bf 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -523,7 +523,10 @@ impl Component for Completion {
None => return,
},
CompletionItem::Other(option) => {
- markdowned(language, None, Some(&option.documentation))
+ let Some(doc) = option.documentation.as_deref() else {
+ return;
+ };
+ markdowned(language, None, Some(doc))
}
};