Compare commits

..
1 Commits
4 changed files with 96 additions and 10 deletions
+1
View File
@@ -312,6 +312,7 @@ and this file is for what someone changing worklane's own code needs.
- **A query turns the truncation off**, which is the point of having one: the campaign a reader is searching for is exactly the one the truncation hid
- **The query is a layer, and `esc` takes it off before it takes the picker off**, the order `dismiss` closes the board's own layers in. So the list is whole again after that press, not still filtered with nothing on screen saying why. Movement and `enter` stay live under an open query, because a filtered list nothing can move in is a list nothing can be chosen from; every *printable* key goes into the buffer, so `q` types and so does `j`
- **The highlight follows its row, not its row number.** `place_picker` takes a key — whichever answer `PickerRow::key` hands back, the same shape `Tab::filter` holds for any of them: typing, clearing the query and a tick that finishes a campaign all reshape the list, and a number kept across that names whichever campaign now sits at it. One the list no longer holds drops the highlight to the first row that does, which is where an incremental filter puts it. `reload` reads the highlighted key before the lists are rebuilt and puts it back after
- **Both ends bring the highlight into the window.** Opening aligns against the screen the dispatch hands `open_picker`, and the draw follows the highlight again through `aligned_offset` on the geometry it is actually drawing — a resize between that keypress and the frame, or a tick that put the highlight back without touching the scroll, cannot leave it below the fold until some later keypress fixes it. The stored offset is left alone, the way a column's is: what is drawn is corrected immediately and the next navigation writes the correction back
- **A miss is a row in the box, `no match` in brightred**, where the search prompt puts its own, and `enter` on it leaves the picker and the query exactly as they are so the query can be corrected in place. An empty box says nothing about why it is empty
- **The picker's footer becomes its query**, the trade `draw_search` makes: with every printable key going into a buffer, a list of keys describes nothing that works. `/ search` is named only on the closed query, and the open one names what `esc` does to *it* rather than what it does to the picker
- **The title says both counts while a query is open**, `campaigns (2 of 6)`. The bare total is what the box is, but over a list a query has cut down it is a lie about what is on screen
Generated
+1 -1
View File
@@ -1503,7 +1503,7 @@ dependencies = [
[[package]]
name = "worklane"
version = "0.32.11"
version = "0.32.12"
dependencies = [
"anyhow",
"assert_cmd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "worklane"
version = "0.32.11"
version = "0.32.12"
edition = "2024"
[dependencies]
+93 -8
View File
@@ -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]