(21713c5) Follow the picker highlight in the draw, not only on the keypress, and bump to 0.32.12
This commit is contained in:
+93
-8
@@ -4026,16 +4026,30 @@ fn draw_picker(frame: &mut Frame, tab: &Tab, picker: &Picker, area: Rect) {
|
||||
Style::default().fg(Color::Orange.into()),
|
||||
));
|
||||
|
||||
// Capped against blank space past the last row, the way an unfocused column is.
|
||||
let last = (lines.len() as u16).saturating_sub(text.height);
|
||||
// Followed on the geometry this frame is drawing, not the one the keypress
|
||||
// measured. Opening aligns against the screen the dispatch hands it, but a resize
|
||||
// between that keypress and here shrinks the window under an offset sized to the
|
||||
// old one, and a tick puts the highlight back by key without touching the scroll at
|
||||
// all. The stored value is left alone, the way a column's is: what is drawn is
|
||||
// corrected immediately and the next navigation writes the correction back. The cap
|
||||
// against blank space past the last row falls out of the same call.
|
||||
// Followed on the geometry this frame is drawing, not the one the keypress
|
||||
// measured. Opening aligns against the screen the dispatch hands it, but a resize
|
||||
// between that keypress and here shrinks the window under an offset sized to the
|
||||
// old one, and a tick puts the highlight back by key without touching the scroll at
|
||||
// all. The stored value is left alone, the way a column's is: what is drawn is
|
||||
// corrected immediately and the next navigation writes the correction back. The cap
|
||||
// against blank space past the last row falls out of the same call.
|
||||
let offset = aligned_offset(
|
||||
picker.offset,
|
||||
picker.row as u16,
|
||||
picker.row as u16 + 1,
|
||||
text.height,
|
||||
lines.len() as u16,
|
||||
);
|
||||
|
||||
frame.render_widget(Clear, overlay);
|
||||
frame.render_widget(
|
||||
Paragraph::new(lines)
|
||||
.block(block)
|
||||
.scroll((picker.offset.min(last), 0)),
|
||||
overlay,
|
||||
);
|
||||
frame.render_widget(Paragraph::new(lines).block(block).scroll((offset, 0)), overlay);
|
||||
}
|
||||
|
||||
/// The picker's own title: how many campaigns the board has, and how many a query left.
|
||||
@@ -11144,6 +11158,77 @@ approach";
|
||||
);
|
||||
}
|
||||
|
||||
/// A board whose picker list is taller than a short window draws, with the campaign
|
||||
/// filtered onto sitting at its foot: the shape where reaching the highlight takes
|
||||
/// scrolling, and `c` on the filtered board looks like `c` on any other until the
|
||||
/// highlight is actually inside the box.
|
||||
///
|
||||
/// Fourteen numbered campaigns sort above it, so the deep one is the last open row;
|
||||
/// with no members anywhere nothing completes, so there is no completed section
|
||||
/// either and the arithmetic stays fixed.
|
||||
fn deep_picker_board(dir: &Path) -> Board {
|
||||
for n in 1..=14 {
|
||||
write_campaign(
|
||||
dir,
|
||||
&format!("{n:02}aaaaaa-0000-4000-8000-000000000000"),
|
||||
&format!("Campaign {n:02}"),
|
||||
&format!("c{n:02}"),
|
||||
"Filler.",
|
||||
);
|
||||
}
|
||||
write_campaign(
|
||||
dir,
|
||||
"ffff9999-0000-4000-8000-000000000000",
|
||||
"Zeppelin survey",
|
||||
"zeppelin",
|
||||
"The one far down.",
|
||||
);
|
||||
|
||||
let mut board = one_board(dir);
|
||||
board
|
||||
.select_filter(Filter::Campaign("ffff9999-0000-4000-8000-000000000000".into()), SCREEN);
|
||||
board
|
||||
}
|
||||
|
||||
/// The picker opens with the highlight inside the drawn window, whatever row the
|
||||
/// selected campaign sits on.
|
||||
#[test]
|
||||
fn the_picker_opens_with_the_highlight_inside_the_window() {
|
||||
let dir = board_dir();
|
||||
let mut board = deep_picker_board(&dir);
|
||||
board.open_picker(PickerKind::Campaign, SCREEN);
|
||||
|
||||
let rows = picker_rows(&board, 100, 20);
|
||||
let deep = short_id("ffff9999-0000-4000-8000-000000000000");
|
||||
assert!(
|
||||
rows.iter().any(|row| row.contains(deep)),
|
||||
"the highlighted campaign opened below the fold: {rows:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The draw brings the highlight into the window on its own geometry, so a terminal
|
||||
/// resized between the keypress that aligned and this frame cannot hide it. Opening
|
||||
/// against a tall screen leaves an offset sized to the old window; the draw corrects
|
||||
/// it without a keypress, the way the draw follows the selected card in a column.
|
||||
#[test]
|
||||
fn a_resize_between_open_and_frame_cannot_hide_the_highlight() {
|
||||
let dir = board_dir();
|
||||
let mut board = deep_picker_board(&dir);
|
||||
let tall = Size { width: 100, height: 60 };
|
||||
board.open_picker(PickerKind::Campaign, tall);
|
||||
|
||||
// Everything fits the tall window, so nothing but the resize stands between the
|
||||
// offset and the top of the list.
|
||||
assert_eq!(board.picker.as_ref().unwrap().offset, 0);
|
||||
|
||||
let rows = picker_rows(&board, 100, 20);
|
||||
let deep = short_id("ffff9999-0000-4000-8000-000000000000");
|
||||
assert!(
|
||||
rows.iter().any(|row| row.contains(deep)),
|
||||
"the draw drew the old window around the highlight: {rows:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// The key is named where a reader has to find it, and left out where the frame's own
|
||||
/// border says how to put a campaign away.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user