Skip to content

Commit 2cf64eb

Browse files
leatyLoricAndre
andauthored
fix: theme not being set with multiple values (#1049)
* fix: theme not being set with multiple values * test(theme): add better theme override tests --------- Co-authored-by: LoricAndre <57358788+LoricAndre@users.noreply.github.com>
1 parent 7375d30 commit 2cf64eb

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

src/theme.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ impl ColorTheme {
355355
if let Some((name, spec)) = pair.split_once(':') {
356356
theme.set_color(name, spec);
357357
} else {
358-
theme = match color {
358+
theme = match pair {
359359
"molokai" => ColorTheme::molokai256(),
360360
"light" => ColorTheme::light256(),
361361
"16" => ColorTheme::default16(),
@@ -568,14 +568,26 @@ mod tests {
568568
}
569569

570570
#[test]
571-
fn test_base_theme_with_overrides() {
572-
// Test that base theme can be overridden
573-
let theme = ColorTheme::from_options("dark,matched:200");
571+
fn test_default_theme_with_overrides() {
572+
// Test overriding default theme
573+
let theme = ColorTheme::from_options("default,matched:200");
574574
assert_eq!(theme.matched.fg, Some(Color::Indexed(200)));
575-
// Other colors should still be from dark theme
575+
// Other colors should still be from default theme
576576
assert!(theme.prompt.fg.is_some());
577577
}
578578

579+
#[test]
580+
fn test_theme_with_overrides() {
581+
// Test overriding theme
582+
for opts in &["16,prompt:200", "prompt:150,16,prompt:200"] {
583+
let theme = ColorTheme::from_options(opts);
584+
assert_eq!(theme.prompt.fg, Some(Color::Indexed(200)));
585+
// Other colors should still be from given theme
586+
assert_eq!(theme.matched.fg, Some(Color::Green));
587+
assert_eq!(theme.matched.bg, None);
588+
}
589+
}
590+
579591
#[test]
580592
fn test_all_component_names() {
581593
// Test all valid component names with their specific colors

0 commit comments

Comments
 (0)