mirror of
https://github.com/sharkdp/bat
synced 2026-06-09 10:03:18 +00:00
feat: preserve change markers when combining --diff with --plain
When --plain is set (via CLI or config file), --diff output loses all visual markers, making it indistinguishable from plain text. The diff line filtering still works, but without Changes markers or Snip separators the output is not useful. Automatically include Changes and Snip style components when --diff is active alongside --plain. This preserves the --plain intent (no grid, no header, no line numbers) while keeping diff output readable. Closes #3630
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
## Features
|
||||
|
||||
- Preserve `--diff` change markers and snip separators when `--plain` is set, see #3630 (@mvanhorn)
|
||||
- Added support for `hidden_file_extensions` from `.sublime-syntax` files, see #3613 (@Matei02355)
|
||||
- Add word wrapping mode via `--wrap=word`, see #3597 (@veeceey)
|
||||
- Implement `--unbuffered` mode for streaming input, allowing partial lines to display immediately (e.g. `tail -f | bat -u`). Closes #3555, see #3583 (@mainnebula)
|
||||
|
||||
+10
-1
@@ -590,7 +590,16 @@ impl App {
|
||||
|
||||
// Plain if `--plain` is specified at least once.
|
||||
if self.matches.get_count("plain") > 0 {
|
||||
return Some(StyleComponents(HashSet::from([StyleComponent::Plain])));
|
||||
let mut components = HashSet::from([StyleComponent::Plain]);
|
||||
// When --diff is active, preserve change markers and snip separators
|
||||
// so that diff output remains visually useful.
|
||||
if self.matches.try_contains_id("diff").unwrap_or_default()
|
||||
&& self.matches.get_flag("diff")
|
||||
{
|
||||
components.insert(StyleComponent::Changes);
|
||||
components.insert(StyleComponent::Snip);
|
||||
}
|
||||
return Some(StyleComponents(components));
|
||||
}
|
||||
|
||||
// Default behavior.
|
||||
|
||||
Reference in New Issue
Block a user