From e14eb05b538a1b2cfe0ff9acf015ecceca1739df Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sun, 22 Nov 2026 08:17:58 +0700 Subject: [PATCH] behavior: a ragged grid's page move passes over rows that cannot take the lead Up and Down already passed over such a row (a closed group's); Page Up and Page Down stayed put when the page landed on one, as on a TileGrid rule head. --- crates/behavior/src/nav/step.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/behavior/src/nav/step.rs b/crates/behavior/src/nav/step.rs index bb93f2df4..d25aff01a 100644 --- a/crates/behavior/src/nav/step.rs +++ b/crates/behavior/src/nav/step.rs @@ -330,17 +330,17 @@ fn ragged_at(outline: &dyn NavOutline, row: usize, column: usize) -> Option NavStep { let Some((row, column, _)) = locate(outline, lead) else { return NavStep::Unhandled }; let rows = (0..).take_while(|&r| outline.row_len(r).is_some()).count(); - // A row without a position that takes the lead (a closed group's) is passed over in the move's direction. + // A row without a position that takes the lead (a closed group's, a divider's) is passed over in the move's + // direction. let shifted = |to: usize| column.saturating_add_signed(outline.column_shift(row, to)); let toward = |rows: Vec| moved(rows.into_iter().find_map(|to| ragged_at(outline, to, shifted(to)))); - let vertical = |to: Option| moved(to.and_then(|to| ragged_at(outline, to, shifted(to)))); match mv { NavMove::Back => moved(neighbour(outline, state, lead, false)), NavMove::Forward => moved(neighbour(outline, state, lead, true)), NavMove::Up => toward((0..row).rev().collect()), NavMove::Down => toward((row + 1..rows).collect()), - NavMove::PageUp => vertical(Some(row.saturating_sub(state.page))), - NavMove::PageDown => vertical(Some((row + state.page).min(rows - 1))), + NavMove::PageUp => toward((0..=row.saturating_sub(state.page)).rev().collect()), + NavMove::PageDown => toward(((row + state.page).min(rows - 1)..rows).collect()), NavMove::Start => moved(first_enabled(outline)), NavMove::End => moved(last_enabled(outline)), }