From e01775a6677df12a94e99938b52771974af7c30c Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+nik-rev@users.noreply.github.com> Date: Sun, 12 Jan 2025 15:40:19 +0000 Subject: [PATCH] fix: unable to detect Color completion item hex code for some LSPs (#12501) Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> --- helix-term/src/ui/completion.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs index adacfad3..030085af 100644 --- a/helix-term/src/ui/completion.rs +++ b/helix-term/src/ui/completion.rs @@ -92,8 +92,11 @@ impl menu::Item for CompletionItem { value, .. }) => value, }; - Color::from_hex(text) + // Language servers which send Color completion items tend to include a 6 + // digit hex code at the end for the color. The extra 1 digit is for the '#' + text.get(text.len().checked_sub(7)?..) }) + .and_then(Color::from_hex) .map_or("color".into(), |color| { Spans::from(vec![ Span::raw("color "),