From b3e36aa1452fcc47a7aed590bf0af71cd9da0556 Mon Sep 17 00:00:00 2001 From: jarommadsen Date: Sun, 2 Jun 2024 13:01:03 -0600 Subject: [PATCH] Wrap around to next row on tab (#395) Co-authored-by: Jarom Madsen --- src/reducer.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/reducer.ts b/src/reducer.ts index 21a87eb9..cb370e6f 100644 --- a/src/reducer.ts +++ b/src/reducer.ts @@ -412,9 +412,12 @@ export const go = if (!state.active) { return; } + const size = Matrix.getSize(state.model.data); + const newColumn = state.active.column + columnDelta; + const shouldWrap = newColumn >= size.columns; const nextActive = { - row: state.active.row + rowDelta, - column: state.active.column + columnDelta, + row: state.active.row + rowDelta + (shouldWrap ? 1 : 0), + column: (state.active.column + columnDelta) % size.columns, }; if (!Matrix.has(nextActive, state.model.data)) { return { ...state, mode: "view" };