Skip to content

Commit d6a7e6f

Browse files
nik-revpaholg
authored andcommitted
fix: unable to detect Color completion item hex code for some LSPs (helix-editor#12501)
Co-authored-by: Nikita Revenco <[email protected]>
1 parent 0862570 commit d6a7e6f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

helix-term/src/ui/completion.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ impl menu::Item for CompletionItem {
9292
value, ..
9393
}) => value,
9494
};
95-
Color::from_hex(text)
95+
// Language servers which send Color completion items tend to include a 6
96+
// digit hex code at the end for the color. The extra 1 digit is for the '#'
97+
text.get(text.len().checked_sub(7)?..)
9698
})
99+
.and_then(Color::from_hex)
97100
.map_or("color".into(), |color| {
98101
Spans::from(vec![
99102
Span::raw("color "),

0 commit comments

Comments
 (0)