diff --git a/Cargo.lock b/Cargo.lock index db7cda10ad..e805011655 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1849,6 +1849,7 @@ checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown 0.15.2", + "serde", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3f6b77768a..7d5c9011c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,7 +67,7 @@ glob = "0.3.1" hashbrown = { version = "0.15.2", default-features = false, features = ["inline-more"] } hex = "0.4.3" ignore = "0.4.23" -indexmap = "2.7.0" +indexmap = { version = "2.7.0", features = ["serde"] } indoc = "2.0.4" insta = { version = "1.41.1", features = ["filters"] } itertools = "0.13.0" diff --git a/cli/src/formatter.rs b/cli/src/formatter.rs index f63bdab014..8213879401 100644 --- a/cli/src/formatter.rs +++ b/cli/src/formatter.rs @@ -709,6 +709,7 @@ mod tests { use std::error::Error as _; use std::str; + use indexmap::IndexMap; use indoc::indoc; use jj_lib::config::ConfigLayer; use jj_lib::config::ConfigSource; @@ -774,11 +775,10 @@ mod tests { bright-cyan = 'bright cyan' bright-white = 'bright white' "}); - // TODO: migrate off config::Config and switch to IndexMap - let colors: HashMap = config.get("colors").unwrap(); + let colors: IndexMap = config.get("colors").unwrap(); let mut output: Vec = vec![]; let mut formatter = ColorFormatter::for_config(&mut output, &config, false).unwrap(); - for (label, color) in colors.iter().sorted() { + for (label, color) in &colors { formatter.push_label(label).unwrap(); write!(formatter, " {color} ").unwrap(); formatter.pop_label().unwrap(); @@ -787,21 +787,21 @@ mod tests { drop(formatter); insta::assert_snapshot!(String::from_utf8(output).unwrap(), @r"  black  +  red  +  green  +  yellow   blue  +  magenta  +  cyan  +  white   bright black  -  bright blue  -  bright cyan  +  bright red   bright green  +  bright yellow  +  bright blue   bright magenta  -  bright red  +  bright cyan   bright white  -  bright yellow  -  cyan  -  green  -  magenta  -  red  -  white  -  yellow  "); } @@ -814,11 +814,10 @@ mod tests { white = '#ffffff' pastel-blue = '#AFE0D9' "}); - // TODO: migrate off config::Config and switch to IndexMap - let colors: HashMap = config.get("colors").unwrap(); + let colors: IndexMap = config.get("colors").unwrap(); let mut output: Vec = vec![]; let mut formatter = ColorFormatter::for_config(&mut output, &config, false).unwrap(); - for label in colors.keys().sorted() { + for label in colors.keys() { formatter.push_label(&label.replace(' ', "-")).unwrap(); write!(formatter, " {label} ").unwrap(); formatter.pop_label().unwrap(); @@ -827,8 +826,8 @@ mod tests { drop(formatter); insta::assert_snapshot!(String::from_utf8(output).unwrap(), @r"  black  -  pastel-blue   white  +  pastel-blue  "); }