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 authored and GitHub committed 2025-09-22 07:42:56 +02:00
1 parent 9d003dd1b9
commit c8b8132228
3 files changed
+35 -17

No files matched your search

+3 -1
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)));
}
}