fix: hide clipped scope labels at the pane top
This commit is contained in:
+11
-4
@@ -4163,7 +4163,7 @@ fn draw_diff_scope_labels(
|
||||
if lefts[pane] <= column && column < lefts[pane].saturating_add(width) {
|
||||
continue;
|
||||
}
|
||||
let Some(y) = y.checked_sub(1).filter(|&y| y >= areas[pane].y) else {
|
||||
let Some(y) = y.checked_sub(1).filter(|&y| y >= content.y) else {
|
||||
continue;
|
||||
};
|
||||
y
|
||||
@@ -8282,10 +8282,11 @@ mod tests {
|
||||
let declaration = diff.source_display_row(Focus::After, 1).unwrap();
|
||||
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(120, 30)).unwrap();
|
||||
let mut panels = WheelPanels::default();
|
||||
// A declaration at the top uses the border rather than displacing its first row.
|
||||
// A declaration at the top has no room for an overlay; leave its border intact.
|
||||
for top in [0, declaration] {
|
||||
diff.top = top;
|
||||
let mut original = None;
|
||||
let mut borders = [None, None];
|
||||
for lefts in [[0, 0], [8, 0], [0, 8], [8, 8], [0, 0]] {
|
||||
[diff.left_before, diff.left_after] = lefts;
|
||||
render_diff(&mut terminal, &diff, &mut panels);
|
||||
@@ -8322,10 +8323,16 @@ mod tests {
|
||||
);
|
||||
assert_eq!(
|
||||
above.contains("review"),
|
||||
left > 0,
|
||||
left > 0 && screen > 0,
|
||||
"Clipped names belong above the declaration, without adding a row"
|
||||
);
|
||||
if left > 0 {
|
||||
if screen == 0 {
|
||||
let border = borders[pane].get_or_insert_with(|| above.clone());
|
||||
assert_eq!(
|
||||
&above, border,
|
||||
"Horizontal scrolling must preserve the border"
|
||||
);
|
||||
} else if left > 0 {
|
||||
assert_eq!(
|
||||
above.trim(),
|
||||
if mode == ViewMode::Unified {
|
||||
|
||||
Reference in New Issue
Block a user