Git · ChangesList: line counts are optional, so binary files and folders show none
This commit is contained in:
3 files changed
+11
-10
No files matched your search
@@ -19,8 +19,7 @@ fn changed(path: &str, status: GitStatus, added: usize, removed: usize) -> Chang
|
|||||||
Changed {
|
Changed {
|
||||||
path: path.to_string().into(),
|
path: path.to_string().into(),
|
||||||
status,
|
status,
|
||||||
added,
|
lines: Some((added, removed)),
|
||||||
removed,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -21,8 +21,8 @@ use crate::{
|
|||||||
pub struct Changed {
|
pub struct Changed {
|
||||||
pub path: SharedString,
|
pub path: SharedString,
|
||||||
pub status: GitStatus,
|
pub status: GitStatus,
|
||||||
pub added: usize,
|
/// Added and removed; None when not counted, as for a binary file or a folder.
|
||||||
pub removed: usize,
|
pub lines: Option<(usize, usize)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// What a changes list asks for a file.
|
/// 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))
|
tabular(div().flex_none().text_color(colors.fg_subtle))
|
||||||
.child(format!("+{} −{}", file.added, file.removed)),
|
.child(format!("+{added} −{removed}"))
|
||||||
)
|
}))
|
||||||
.into_any_element()
|
.into_any_element()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -85,8 +85,7 @@ impl Render for Sorted {
|
|||||||
let file = |path: &str, status| super::Changed {
|
let file = |path: &str, status| super::Changed {
|
||||||
path: path.to_string().into(),
|
path: path.to_string().into(),
|
||||||
status,
|
status,
|
||||||
added: 1,
|
lines: Some((1, 0)),
|
||||||
removed: 0,
|
|
||||||
};
|
};
|
||||||
div().w(px(420.0)).child(
|
div().w(px(420.0)).child(
|
||||||
super::ChangesList::new(
|
super::ChangesList::new(
|
||||||
@@ -96,7 +95,10 @@ impl Render for Sorted {
|
|||||||
)
|
)
|
||||||
.conflicted([file("c.rs", GitStatus::Conflicted)])
|
.conflicted([file("c.rs", GitStatus::Conflicted)])
|
||||||
.untracked([file("d.rs", GitStatus::Untracked)])
|
.untracked([file("d.rs", GitStatus::Untracked)])
|
||||||
.ignored([file("target/", GitStatus::Untracked)]),
|
.ignored([super::Changed {
|
||||||
|
lines: None,
|
||||||
|
..file("target/", GitStatus::Untracked)
|
||||||
|
}]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user