From ee1ba24d7b13906a8bc62b45927288c4c35ca375 Mon Sep 17 00:00:00 2001 From: bashbunni Date: Fri, 20 Sep 2024 11:09:48 -0700 Subject: [PATCH] refactor(table): use maxYOffset --- table/table.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/table/table.go b/table/table.go index 68d3f53..32ea7d7 100644 --- a/table/table.go +++ b/table/table.go @@ -381,7 +381,7 @@ func (m *Model) MoveUp(n int) { // only set the offset outside of the last available rows. // TODO use maxYOffset - if m.cursor < len(m.rows)-m.height { + if m.cursor < m.maxYOffset() { m.YOffset = m.YOffset - n m.table.Offset(m.YOffset) } @@ -425,8 +425,7 @@ func (m *Model) MoveDown(n int) { // check if we're in the last set of rows before truncation would // happen. - if m.cursor < len(m.rows)-m.height { - // TODO use maxOffset? + if m.cursor < m.maxYOffset() { m.YOffset = m.YOffset + n m.table.Offset(m.YOffset) }