1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-02-14 17:08:37 +00:00

Fix: Don't output default theme info to piped stdout

This commit is contained in:
einfachIrgendwer0815 2025-01-27 16:40:29 +01:00
parent f8c6e90647
commit 4f161705a3
No known key found for this signature in database
GPG Key ID: 58D55E5F117DA873
2 changed files with 9 additions and 6 deletions

View File

@ -210,7 +210,7 @@ pub fn list_themes(
let default_theme_name = default_theme(color_scheme(detect_color_scheme).unwrap_or_default());
for theme in assets.themes() {
let default_theme_info = if !config.loop_through && default_theme_name == theme {
let default_theme_info = if default_theme_name == theme {
" (default)"
} else if default_theme(ColorScheme::Dark) == theme {
" (default dark)"
@ -231,6 +231,8 @@ pub fn list_themes(
.run(vec![theme_preview_file()], None)
.ok();
writeln!(stdout)?;
} else if config.loop_through {
writeln!(stdout, "{theme}")?;
} else {
writeln!(stdout, "{theme}{default_theme_info}")?;
}

View File

@ -305,11 +305,12 @@ fn list_themes_without_colors() {
#[test]
fn list_themes_to_piped_output() {
bat()
.arg("--list-themes")
.assert()
.success()
.stdout(predicate::str::contains("(default)").not());
bat().arg("--list-themes").assert().success().stdout(
predicate::str::contains("(default)")
.not()
.and(predicate::str::contains("(default light)").not())
.and(predicate::str::contains("(default dark)").not()),
);
}
#[test]