Skip to content

Commit

Permalink
core: Make completion item documentation optional
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
the-mikedavis committed Feb 2, 2025
1 parent 369f2bb commit 70d452d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion helix-core/src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
2 changes: 1 addition & 1 deletion helix-term/src/handlers/completion/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}))
})
Expand Down
5 changes: 4 additions & 1 deletion helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
};

Expand Down

0 comments on commit 70d452d

Please sign in to comment.