theme: 🔨 not deserialize no color and no lscolors from config

Signed-off-by: zwPapEr <zw.paper@gmail.com>
This commit is contained in:
zwPapEr
2021-09-09 14:22:02 +08:00
committed by Abin Simon
parent d58a7a3656
commit 861822cb04
2 changed files with 8 additions and 4 deletions

View File

@@ -462,7 +462,12 @@ mod tests {
.to_string();
// check if the color is present.
assert_eq!(true, output.starts_with("\u{1b}[38;5;"), "start with color");
assert_eq!(
true,
output.starts_with("\u{1b}[38;5;"),
"{:?} should start with color",
output,
);
assert_eq!(true, output.ends_with("[39m"), "reset foreground color");
assert_eq!(get_visible_width(&output), *l, "visible match");

View File

@@ -38,6 +38,7 @@ impl Color {
pub enum ThemeOption {
NoColor,
Default,
#[allow(dead_code)]
NoLscolors,
Custom(String),
}
@@ -76,7 +77,7 @@ impl<'de> de::Deserialize<'de> for ThemeOption {
type Value = ThemeOption;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("`no-color`, `default`, `no-lscolors` or <theme-file-path>")
formatter.write_str("`default` or <theme-file-path>")
}
fn visit_str<E>(self, value: &str) -> Result<ThemeOption, E>
@@ -84,9 +85,7 @@ impl<'de> de::Deserialize<'de> for ThemeOption {
E: de::Error,
{
match value {
"no-color" => Ok(ThemeOption::NoColor),
"default" => Ok(ThemeOption::Default),
"no-lscolors" => Ok(ThemeOption::NoLscolors),
str => Ok(ThemeOption::Custom(str.to_string())),
}
}