Skip to content

Commit

Permalink
fix: unable to detect Color completion item hex code for some LSPs (h…
Browse files Browse the repository at this point in the history
…elix-editor#12501)

Co-authored-by: Nikita Revenco <[email protected]>
  • Loading branch information
2 people authored and rmburg committed Jan 20, 2025
1 parent 4360634 commit 833d42c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 "),
Expand Down

0 comments on commit 833d42c

Please sign in to comment.