From 54f28b650198f96080f16c0cba1e480f4457ec0a Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 20 Mar 2025 14:00:29 -0300 Subject: [PATCH] fix(filepicker): properly scrolling filepicker (#753) * fix(filepicker): properly scrolling filepicker Signed-off-by: Carlos Alexandro Becker * fix: SetHeight Signed-off-by: Carlos Alexandro Becker --------- Signed-off-by: Carlos Alexandro Becker --- filepicker/filepicker.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/filepicker/filepicker.go b/filepicker/filepicker.go index ec96e3d..487ca96 100644 --- a/filepicker/filepicker.go +++ b/filepicker/filepicker.go @@ -158,6 +158,9 @@ type Model struct { maxStack stack minStack stack + // Height of the picker. + // + // Deprecated: use [Model.SetHeight] instead. Height int AutoHeight bool @@ -233,6 +236,14 @@ func (m Model) Init() tea.Cmd { return m.readDir(m.CurrentDirectory, m.ShowHidden) } +// SetHeight sets the height of the filepicker. +func (m *Model) SetHeight(height int) { + m.Height = height + if m.max > m.Height-1 { + m.max = m.min + m.Height - 1 + } +} + // Update handles user interactions within the file picker model. func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { switch msg := msg.(type) {