From b7f7e2528b17b3ba1bba7da1d87a7b12397ea130 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:08:27 +0000 Subject: [PATCH] feat: do not add unnecessary custom method --- Cargo.lock | 2 +- helix-term/Cargo.toml | 2 ++ helix-term/src/ui/completion.rs | 5 ++++- helix-view/Cargo.toml | 2 -- helix-view/src/graphics.rs | 7 ------- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 322d1d66..6897e953 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index 5b46a261..a8810eed 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -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" diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs index ff4cbc9e..76ab1ad1 100644 --- a/helix-term/src/ui/completion.rs +++ b/helix-term/src/ui/completion.rs @@ -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"), } diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml index 8247bab4..6f71fa05 100644 --- a/helix-view/Cargo.toml +++ b/helix-view/Cargo.toml @@ -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" diff --git a/helix-view/src/graphics.rs b/helix-view/src/graphics.rs index 45d3d1a1..a26823b9 100644 --- a/helix-view/src/graphics.rs +++ b/helix-view/src/graphics.rs @@ -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 { - HexColor::parse_rgb(hex).map(|c| Self::Rgb(c.r, c.g, c.b)) - } -} - #[cfg(feature = "term")] impl From for crossterm::style::Color { fn from(color: Color) -> Self {