From c3c3481ef5964f806be486a52dea000b47209919 Mon Sep 17 00:00:00 2001 From: David Matos Date: Wed, 23 Nov 2022 23:32:25 +0100 Subject: [PATCH] fix color_config crashing on nonstring data (#7215) This PR closses issue #7155, where now providing a non valid color will just ignore it and use the default. Making the same changes as the original issue just starts nushell without crashing. --- crates/nu-color-config/src/color_config.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/crates/nu-color-config/src/color_config.rs b/crates/nu-color-config/src/color_config.rs index c4d31d6110..8dd5edc645 100644 --- a/crates/nu-color-config/src/color_config.rs +++ b/crates/nu-color-config/src/color_config.rs @@ -217,15 +217,10 @@ pub fn get_color_config(config: &Config) -> HashMap { hm.insert("hints".to_string(), Color::DarkGray.normal()); for (key, value) in &config.color_config { - let value = value - .as_string() - .expect("the only values for config color must be strings"); - update_hashmap(key, &value, &mut hm); - - // eprintln!( - // "config: {}:{}\t\t\thashmap: {}:{:?}", - // &key, &value, &key, &hm[key] - // ); + match value.as_string() { + Ok(value) => update_hashmap(key, &value, &mut hm), + Err(_) => continue, + } } hm