fix apply patch when only one file is rendered (#2468)
<img width="809" height="87" alt="image" src="https://github.com/user-attachments/assets/6fe69643-10d7-4420-bbf2-e30c092b800f" />
This commit is contained in:
@@ -695,7 +695,7 @@ fn apply_patch_request_shows_diff_summary() {
|
|||||||
|
|
||||||
// Per-file summary line should include the file path and counts
|
// Per-file summary line should include the file path and counts
|
||||||
assert!(
|
assert!(
|
||||||
blob.contains("README.md (+2 -0)"),
|
blob.contains("README.md"),
|
||||||
"missing per-file diff summary: {blob:?}"
|
"missing per-file diff summary: {blob:?}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,17 +130,20 @@ pub(crate) fn create_diff_summary(
|
|||||||
for (idx, f) in files.iter().enumerate() {
|
for (idx, f) in files.iter().enumerate() {
|
||||||
let mut spans: Vec<RtSpan<'static>> = Vec::new();
|
let mut spans: Vec<RtSpan<'static>> = Vec::new();
|
||||||
spans.push(RtSpan::raw(f.display_path.clone()));
|
spans.push(RtSpan::raw(f.display_path.clone()));
|
||||||
spans.push(RtSpan::raw(" ("));
|
// Show per-file +/- counts only when there are multiple files
|
||||||
spans.push(RtSpan::styled(
|
if file_count > 1 {
|
||||||
format!("+{}", f.added),
|
spans.push(RtSpan::raw(" ("));
|
||||||
Style::default().fg(Color::Green),
|
spans.push(RtSpan::styled(
|
||||||
));
|
format!("+{}", f.added),
|
||||||
spans.push(RtSpan::raw(" "));
|
Style::default().fg(Color::Green),
|
||||||
spans.push(RtSpan::styled(
|
));
|
||||||
format!("-{}", f.removed),
|
spans.push(RtSpan::raw(" "));
|
||||||
Style::default().fg(Color::Red),
|
spans.push(RtSpan::styled(
|
||||||
));
|
format!("-{}", f.removed),
|
||||||
spans.push(RtSpan::raw(")"));
|
Style::default().fg(Color::Red),
|
||||||
|
));
|
||||||
|
spans.push(RtSpan::raw(")"));
|
||||||
|
}
|
||||||
|
|
||||||
let mut line = RtLine::from(spans);
|
let mut line = RtLine::from(spans);
|
||||||
let prefix = if idx == 0 { " └ " } else { " " };
|
let prefix = if idx == 0 { " └ " } else { " " };
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ source: tui/src/diff_render.rs
|
|||||||
expression: terminal.backend()
|
expression: terminal.backend()
|
||||||
---
|
---
|
||||||
"proposed patch to 1 file (+2 -0) "
|
"proposed patch to 1 file (+2 -0) "
|
||||||
" └ README.md (+2 -0) "
|
" └ README.md "
|
||||||
" 1 +first line "
|
" 1 +first line "
|
||||||
" 2 +second line "
|
" 2 +second line "
|
||||||
" "
|
" "
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ assertion_line: 380
|
|||||||
expression: terminal.backend()
|
expression: terminal.backend()
|
||||||
---
|
---
|
||||||
"proposed patch to 1 file (+1 -1) "
|
"proposed patch to 1 file (+1 -1) "
|
||||||
" └ src/lib.rs → src/lib_new.rs (+1 -1) "
|
" └ src/lib.rs → src/lib_new.rs "
|
||||||
" 1 line one "
|
" 1 line one "
|
||||||
" 2 -line two "
|
" 2 -line two "
|
||||||
" 2 +line two changed "
|
" 2 +line two changed "
|
||||||
|
|||||||
Reference in New Issue
Block a user