diff --git a/CHANGELOG.md b/CHANGELOG.md index a742e6fd..090a019c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Syntax highlighting for Python files using uv as script runner in shebang #3689 (@janlarres) ## Bugfixes +- Fix `--list-themes` unconditionally probing the terminal via OSC 10/11 even when `--theme` was set to an explicit value, see #3700 (regression introduced in bc42149a). (@optimistiCli) - Fix inverted `$LESSCLOSE` warning so bat warns on nonzero exit, not on success. See #3654 (@cuiweixie) - Sanitize control characters in filenames before displaying them in the file header, error messages, and the terminal title, preventing ANSI escape injection via crafted filenames. Closes #3054, see #3691 (@curious-rabbit) - Report initial input read errors instead of treating them as empty input. Closes #3002, see #3706 (@lawrence3699) diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index f95bbb91..3124cdcd 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -645,7 +645,7 @@ impl App { Ok(styled_components) } - fn theme_options(&self) -> ThemeOptions { + pub(crate) fn theme_options(&self) -> ThemeOptions { Self::theme_options_from_matches(&self.matches) } diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index 71ed8527..1d89f8ec 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -17,7 +17,6 @@ use std::path::Path; use std::process; use bat::output::{OutputHandle, OutputType}; -use bat::theme::DetectColorScheme; use nu_ansi_term::Color::Green; use nu_ansi_term::Style; @@ -39,7 +38,7 @@ use bat::{ error::*, input::Input, style::{StyleComponent, StyleComponents}, - theme::{color_scheme, default_theme, ColorScheme}, + theme::{default_theme, theme, ColorScheme, ThemeOptions}, MappingTarget, PagingMode, }; @@ -197,7 +196,7 @@ pub fn list_themes( cfg: &Config, config_dir: &Path, cache_dir: &Path, - detect_color_scheme: DetectColorScheme, + theme_options: ThemeOptions, ) -> Result<()> { let assets = assets_from_cache_or_binary(cfg.use_custom_assets, cache_dir)?; let mut config = cfg.clone(); @@ -206,7 +205,7 @@ pub fn list_themes( config.language = Some("Rust"); config.style_components = StyleComponents(style); - let default_theme_name = default_theme(color_scheme(detect_color_scheme).unwrap_or_default()); + let default_theme_name = theme(theme_options).to_string(); let mut buf = String::new(); let mut handle = OutputHandle::FmtWrite(&mut buf); @@ -428,7 +427,7 @@ fn run() -> Result { }; run_controller(inputs, &plain_config, cache_dir) } else if app.matches.get_flag("list-themes") { - list_themes(&config, config_dir, cache_dir, DetectColorScheme::default())?; + list_themes(&config, config_dir, cache_dir, app.theme_options())?; Ok(true) } else if app.matches.get_flag("config-file") { println!("{}", config_file().to_string_lossy());