Git · ChangesList: line counts are optional, so binary files and folders show none

This commit is contained in:
ZacharyZhang-NY committed 2026-10-06 22:55:43 -04:00
1 parent 490b0220f6
commit 4f8f3bd4c4
3 files changed
+11 -10

No files matched your search

+5 -5
View File
@@ -21,8 +21,8 @@ use crate::{
pub struct Changed {
pub path: SharedString,
pub status: GitStatus,
pub added: usize,
pub removed: usize,
/// Added and removed; None when not counted, as for a binary file or a folder.
pub lines: Option<(usize, usize)>,
}
/// What a changes list asks for a file.
@@ -234,10 +234,10 @@ impl ChangesList {
},
),
)
.child(
.children(file.lines.map(|(added, removed)| {
tabular(div().flex_none().text_color(colors.fg_subtle))
.child(format!("+{} −{}", file.added, file.removed)),
)
.child(format!("+{added} −{removed}"))
}))
.into_any_element()
}
+5 -3
View File
@@ -85,8 +85,7 @@ impl Render for Sorted {
let file = |path: &str, status| super::Changed {
path: path.to_string().into(),
status,
added: 1,
removed: 0,
lines: Some((1, 0)),
};
div().w(px(420.0)).child(
super::ChangesList::new(
@@ -96,7 +95,10 @@ impl Render for Sorted {
)
.conflicted([file("c.rs", GitStatus::Conflicted)])
.untracked([file("d.rs", GitStatus::Untracked)])
.ignored([file("target/", GitStatus::Untracked)]),
.ignored([super::Changed {
lines: None,
..file("target/", GitStatus::Untracked)
}]),
)
}
}