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.
This commit is contained in:
David Matos 2022-11-23 23:32:25 +01:00 committed by GitHub
parent 0732d8bbba
commit c3c3481ef5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -217,15 +217,10 @@ pub fn get_color_config(config: &Config) -> HashMap<String, Style> {
hm.insert("hints".to_string(), Color::DarkGray.normal()); hm.insert("hints".to_string(), Color::DarkGray.normal());
for (key, value) in &config.color_config { for (key, value) in &config.color_config {
let value = value match value.as_string() {
.as_string() Ok(value) => update_hashmap(key, &value, &mut hm),
.expect("the only values for config color must be strings"); Err(_) => continue,
update_hashmap(key, &value, &mut hm); }
// eprintln!(
// "config: {}:{}\t\t\thashmap: {}:{:?}",
// &key, &value, &key, &hm[key]
// );
} }
hm hm