From e350bef1f997bbdd3ad96737bdeb02bcd83f6710 Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Thu, 7 Mar 2024 17:23:12 +0100 Subject: [PATCH] Fixed an infinite loop after clearing a selected cell. Fixes #944 --- table.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/table.go b/table.go index 84ec8ed..010b124 100644 --- a/table.go +++ b/table.go @@ -1422,7 +1422,6 @@ func (t *Table) InputHandler() func(event *tcell.EventKey, setFocus func(p Primi down = func() { if t.rowsSelectable { - row, column := t.selectedRow, t.selectedColumn t.selectedRow++ if t.selectedRow >= rowCount { if t.wrapVertically { @@ -1431,6 +1430,7 @@ func (t *Table) InputHandler() func(event *tcell.EventKey, setFocus func(p Primi t.selectedRow = rowCount - 1 } } + row, column := t.selectedRow, t.selectedColumn finalRow, finalColumn := rowCount-1, lastColumn if t.wrapVertically { finalRow = row @@ -1447,7 +1447,6 @@ func (t *Table) InputHandler() func(event *tcell.EventKey, setFocus func(p Primi up = func() { if t.rowsSelectable { - row, column := t.selectedRow, t.selectedColumn t.selectedRow-- if t.selectedRow < 0 { if t.wrapVertically { @@ -1456,6 +1455,7 @@ func (t *Table) InputHandler() func(event *tcell.EventKey, setFocus func(p Primi t.selectedRow = 0 } } + row, column := t.selectedRow, t.selectedColumn finalRow, finalColumn := 0, 0 if t.wrapVertically { finalRow = row