feat: default diffs to branch changes

This commit is contained in:
Valdemar Lorenzen
2026-10-13 10:41:37 +02:00
parent fafec2a6b0
commit 6c254f9b0d
10 changed files with 562 additions and 33 deletions
+13 -6
View File
@@ -2343,7 +2343,7 @@ fn draw_diff(
} else {
"After"
};
let title = format!(" Diff · Choose {stage} ");
let title = format!(" Diff · Choose {stage} · {} ", diff.comparison_mode.label());
let content = diff_panel(frame, panel, &title, "", "", true);
let notice = diff.error.as_deref().or_else(|| {
if diff.loading {
@@ -2381,7 +2381,11 @@ fn draw_diff(
.as_ref()
.map_or("not selected", |revision| revision.label.as_str());
frame.render_widget(
Paragraph::new(format!("Choose {stage} · Before: {}", display_text(before))),
Paragraph::new(format!(
"{} · Ctrl+b toggle · Before: {}",
diff.comparison_mode.label(),
display_text(before)
)),
stage_area,
);
if let Some(catalog) = &diff.catalog {
@@ -2869,7 +2873,7 @@ fn diff_pane_panel(
return area;
}
let title = file.map_or_else(
|| " Diff ".into(),
|| format!(" Diff · {} ", diff.comparison_mode.label()),
|file| {
let label = if diff.view_mode == ViewMode::Unified {
if before {
@@ -2888,9 +2892,10 @@ fn diff_pane_panel(
&file.path
};
format!(
" {label} · {} · {} ",
" {label} · {} · {} · {} ",
diff_status(file.status),
display_text(&path.to_string_lossy())
display_text(&path.to_string_lossy()),
diff.comparison_mode.label()
)
},
);
@@ -5179,7 +5184,9 @@ mod tests {
assert!(text.contains("> commit-19"));
diff.handle(Input::Enter);
render_diff(&mut terminal, &diff, &mut panels);
assert!(screen_text(&terminal).contains("Choose After · Before: commit-19"));
let text = screen_text(&terminal);
assert!(text.contains("Choose After"));
assert!(text.contains("Branch changes · Ctrl+b toggle · Before: commit-19"));
assert!(screen_text(&terminal).contains("Tab categories"));
assert!(screen_text(&terminal).contains("Enter select"));
diff.handle(Input::Ctrl('u'));