mirror of
https://github.com/sharkdp/bat
synced 2026-06-09 10:03:18 +00:00
Merge pull request #3700 from optimistiCli/list-themes-term-probe-fix
Fixed hardcoded terminal probing when `--list-themes` is called
This commit is contained in:
@@ -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)
|
||||
|
||||
+1
-1
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -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<bool> {
|
||||
};
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user