From 10545dc4e1f6fea30bfb416efb2a629cc02bb719 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Mon, 9 Nov 2026 23:30:29 +0100 Subject: [PATCH] fix(selection): keep the old walk when the hidden axis has no direction Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/edit/selection.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/edit/selection.rs b/crates/engine/src/cmd/edit/selection.rs index e85d537ec..e6037c09d 100644 --- a/crates/engine/src/cmd/edit/selection.rs +++ b/crates/engine/src/cmd/edit/selection.rs @@ -94,10 +94,14 @@ pub(super) fn selection_move(s: &mut Session, p: &Json) -> Result { while (sheet.is_row_hidden(t.row) || sheet.is_col_hidden(t.col)) && guard < 100_000 { // Step each hidden axis along its own direction, so a diagonal exit from a merge // (Tab-run return column) keeps its column while skipping hidden rows. - let n = CellRef::new( + let mut n = CellRef::new( if sheet.is_row_hidden(t.row) { t.offset_clamped(dr.signum(), 0).row } else { t.row }, if sheet.is_col_hidden(t.col) { t.offset_clamped(0, dc.signum()).col } else { t.col }, ); + if n == t { + // The hidden axis has no direction (a move along the other axis): walk as before. + n = t.offset_clamped(dr.signum(), dc.signum()); + } if n == t { break; }