From ac131612d0447dd12b1c1e0b6208b8818274302e Mon Sep 17 00:00:00 2001 From: dzeleniak Date: Mon, 6 Nov 2023 07:49:17 -0800 Subject: [PATCH 1/3] Fix bug in moving up in table --- table/table.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/table/table.go b/table/table.go index 36549e3b..631771d9 100644 --- a/table/table.go +++ b/table/table.go @@ -329,7 +329,7 @@ func (m *Model) MoveUp(n int) { case m.start == 0: m.viewport.SetYOffset(clamp(m.viewport.YOffset, 0, m.cursor)) case m.start < m.viewport.Height: - m.viewport.SetYOffset(clamp(m.viewport.YOffset+n, 0, m.cursor)) + m.viewport.YOffset = (clamp(clamp(m.viewport.YOffset+1, 0, m.cursor), 0, m.viewport.Height)) case m.viewport.YOffset >= 1: m.viewport.YOffset = clamp(m.viewport.YOffset+n, 1, m.viewport.Height) } From 06b3dcb7cb31c7b801014081ca00df5d994cf0af Mon Sep 17 00:00:00 2001 From: dzeleniak Date: Mon, 6 Nov 2023 07:55:14 -0800 Subject: [PATCH 2/3] fix --- table/table.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/table/table.go b/table/table.go index 631771d9..954dc592 100644 --- a/table/table.go +++ b/table/table.go @@ -329,7 +329,7 @@ func (m *Model) MoveUp(n int) { case m.start == 0: m.viewport.SetYOffset(clamp(m.viewport.YOffset, 0, m.cursor)) case m.start < m.viewport.Height: - m.viewport.YOffset = (clamp(clamp(m.viewport.YOffset+1, 0, m.cursor), 0, m.viewport.Height)) + m.viewport.YOffset = (clamp(clamp(m.viewport.YOffset+n, 0, m.cursor), 0, m.viewport.Height)) case m.viewport.YOffset >= 1: m.viewport.YOffset = clamp(m.viewport.YOffset+n, 1, m.viewport.Height) } From 4f524ae48ce2fc05f9bd06050f4bdc624e979d09 Mon Sep 17 00:00:00 2001 From: dzeleniak Date: Tue, 7 Nov 2023 17:25:55 -0800 Subject: [PATCH 3/3] Fix table viewport scroll down too early --- table/table.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/table/table.go b/table/table.go index 954dc592..ec0a4a8e 100644 --- a/table/table.go +++ b/table/table.go @@ -343,9 +343,9 @@ func (m *Model) MoveDown(n int) { m.UpdateViewport() switch { - case m.end == len(m.rows): + case m.end == len(m.rows) && m.viewport.YOffset > 0: m.viewport.SetYOffset(clamp(m.viewport.YOffset-n, 1, m.viewport.Height)) - case m.cursor > (m.end-m.start)/2: + case m.cursor > (m.end-m.start)/2 && m.viewport.YOffset > 0: m.viewport.SetYOffset(clamp(m.viewport.YOffset-n, 1, m.cursor)) case m.viewport.YOffset > 1: case m.cursor > m.viewport.YOffset+m.viewport.Height-1: