feat: do not add unnecessary custom method

This commit is contained in:
Nikita Revenco 2024-12-19 16:08:27 +00:00
parent f1281b1634
commit b7f7e2528b
5 changed files with 7 additions and 11 deletions

2
Cargo.lock generated
View file

@ -1387,6 +1387,7 @@ dependencies = [
"helix-tui",
"helix-vcs",
"helix-view",
"hex_color",
"ignore",
"indoc",
"libc",
@ -1461,7 +1462,6 @@ dependencies = [
"helix-stdx",
"helix-tui",
"helix-vcs",
"hex_color",
"libc",
"log",
"once_cell",

View file

@ -49,6 +49,8 @@ fern = "0.7"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
log = "0.4"
hex_color = "3.0"
# File picker
nucleo.workspace = true
ignore = "0.4"

View file

@ -12,6 +12,7 @@ use helix_view::{
theme::{Color, Modifier, Style},
ViewId,
};
use hex_color::HexColor;
use tui::{buffer::Buffer as Surface, text::Span};
use std::{borrow::Cow, sync::Arc};
@ -94,7 +95,9 @@ impl menu::Item for CompletionItem {
first_cell,
maybe_hex_color
.map_or(Span::raw("color"), |hex_color| {
match Color::from_hex(hex_color) {
match HexColor::parse_rgb(hex_color)
.map(|c| Color::Rgb(c.r, c.g, c.b))
{
Ok(l) => Span::styled(" ", Style::default().bg(l)),
Err(_) => Span::raw("color"),
}

View file

@ -44,8 +44,6 @@ slotmap = "1"
chardetng = "0.1"
hex_color = "3.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.8"

View file

@ -1,5 +1,4 @@
use bitflags::bitflags;
use hex_color::{HexColor, ParseHexColorError};
use serde::{Deserialize, Serialize};
use std::{
cmp::{max, min},
@ -264,12 +263,6 @@ pub enum Color {
Indexed(u8),
}
impl Color {
pub fn from_hex(hex: &str) -> Result<Self, ParseHexColorError> {
HexColor::parse_rgb(hex).map(|c| Self::Rgb(c.r, c.g, c.b))
}
}
#[cfg(feature = "term")]
impl From<Color> for crossterm::style::Color {
fn from(color: Color) -> Self {