fix(selection): Enter from a merged cell keeps the Tab run's column

Leaving a merged cell downwards kept the start column and dropped the
column offset Enter passes to return to the Tab run's start column, so
Tab A2 -> B2:C3, Enter landed on B4 instead of A4. Keep the computed
column (and the computed row when leaving to the right).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vangel76andClaude Opus 5.5 committed 2026-11-08 23:22:22 +01:00
1 parent 2bc50341a0
commit 5e5b5d082d
2 files changed
+10 -2

No files matched your search

+2 -2
View File
@@ -85,9 +85,9 @@ pub(super) fn selection_move(s: &mut Session, p: &Json) -> Result<Json> {
if !extend && let Some(m) = sheet.merge_at(from) {
// Leaving a merged cell moves from its edge.
if dr > 0 {
t = CellRef::new(m.end.offset_clamped(dr, 0).row, from.col);
t = CellRef::new(m.end.offset_clamped(dr, 0).row, t.col);
} else if dc > 0 {
t = CellRef::new(from.row, m.end.offset_clamped(0, dc).col);
t = CellRef::new(t.row, m.end.offset_clamped(0, dc).col);
}
}
let mut guard = 0;
+8
View File
@@ -537,5 +537,13 @@ mod merged_cell_enter_tests {
assert_eq!(sel(&app), "D2");
app.move_after_enter(1, 0);
assert_eq!(sel(&app), "A3");
// Enter straight from the merged cell in a Tab run leaves it below its bottom edge and
// still goes back to the run's start column.
app.tab_run = None;
app.run("selection.set", json!({"cell": "A2"})).unwrap();
app.move_after_enter(0, 1);
assert_eq!(sel(&app), "B2:C3");
app.move_after_enter(1, 0);
assert_eq!(sel(&app), "A4");
}
}