1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-29 00:22:26 +01:00

Only leave space for git diff markers if any line is modified (#3406)

Previously, setting `--style=changes` would always print a 2-space
indent, even if the file was unmodified. This changes the style to only
print an indent if there is at least one +/- git marker in the sidebar.
This commit is contained in:
jyn
2025-09-21 22:42:56 -07:00
committed by GitHub
parent 9d003dd1b9
commit c8b8132228
3 changed files with 35 additions and 17 deletions

View File

@@ -227,7 +227,9 @@ impl<'a> InteractivePrinter<'a> {
#[cfg(feature = "git")]
{
if config.style_components.changes() {
if config.style_components.changes()
&& line_changes.as_ref().is_some_and(|c| !c.is_empty())
{
decorations.push(Box::new(LineChangesDecoration::new(&colors)));
}
}