From 70d452db3e0890e13f8ce9d88b861fa39fb6d95c Mon Sep 17 00:00:00 2001
From: Michael Davis <mcarsondavis@gmail.com>
Date: Sat, 1 Feb 2025 21:24:25 -0500
Subject: [PATCH] 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.
---
 helix-core/src/completion.rs               | 2 +-
 helix-term/src/handlers/completion/path.rs | 2 +-
 helix-term/src/ui/completion.rs            | 5 ++++-
 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))
             }
         };