improve: show whole-diff totals alongside file stats

This commit is contained in:
Valdemar Lorenzen
2026-10-20 12:29:06 +02:00
parent a5a246db77
commit 759947736e
15 changed files with 394 additions and 48 deletions
+20
View File
@@ -789,6 +789,7 @@ fn comparison() -> Comparison {
files: vec![
ChangedFile {
review_revisions: None,
stats: None,
path: "renamed.txt".into(),
old_path: Some("old.txt".into()),
status: FileStatus::Renamed,
@@ -827,6 +828,7 @@ fn comparison() -> Comparison {
},
ChangedFile {
review_revisions: None,
stats: None,
path: "added.txt".into(),
old_path: None,
status: FileStatus::Added,
@@ -845,6 +847,7 @@ fn comparison() -> Comparison {
},
ChangedFile {
review_revisions: None,
stats: None,
path: "removed.bin".into(),
old_path: None,
status: FileStatus::Removed,
@@ -860,6 +863,19 @@ fn comparison() -> Comparison {
}
}
#[test]
fn line_counts_use_frozen_metadata_only_until_hunks_are_loaded() {
let mut file = comparison().files.remove(0);
file.loaded = false;
assert_eq!(file.line_counts(), None);
file.stats = Some((99, 98));
assert_eq!(file.line_counts(), Some((99, 98)));
file.loaded = true;
assert_eq!(file.line_counts(), Some((2, 2)));
file.hunks.clear();
assert_eq!(file.line_counts(), Some((0, 0)));
}
#[test]
fn status_layout_cycles_only_present_panes_and_normalizes_selection() {
let mut state = live_state(vec!["old".into()], vec!["new".into()], true);
@@ -1566,6 +1582,7 @@ fn closing_diff_rejects_pending_file_details_even_after_reopening() {
catalog.files.clear();
catalog.files.push(ChangedFile {
review_revisions: None,
stats: None,
path: detail.path.clone(),
old_path: detail.old_path.clone(),
status: detail.status,
@@ -1816,6 +1833,7 @@ fn live_state(before: Vec<String>, after: Vec<String>, eof: bool) -> DiffState {
editable_paths: BTreeSet::from([PathBuf::from("file")]),
files: vec![ChangedFile {
review_revisions: None,
stats: None,
path: "file".into(),
old_path: None,
status: FileStatus::Modified,
@@ -2503,6 +2521,7 @@ fn reverting_loaded_file_keeps_unloaded_changes_selectable() {
state.pending = None;
state.comparison.as_mut().unwrap().files.push(ChangedFile {
review_revisions: None,
stats: None,
path: "unloaded.txt".into(),
old_path: None,
status: FileStatus::Modified,
@@ -2731,6 +2750,7 @@ fn lazy_selection_waits_for_details_rejects_stale_files_and_reuses_loaded_cache(
for detail in &details {
catalog.files.push(ChangedFile {
review_revisions: None,
stats: None,
path: detail.path.clone(),
old_path: detail.old_path.clone(),
status: detail.status,