@@ -55,6 +55,9 @@ type FilePicker struct {
// Notice phase.
notice string
+ // Layout.
+ lastSize *tea.WindowSizeMsg
+
// Result.
includes []string
selection string
@@ -97,6 +100,12 @@ func (fp *FilePicker) Init() tea.Cmd {
// Update handles messages across all phases.
func (fp *FilePicker) Update(msg tea.Msg) (ui.Screen, tea.Cmd) {
+ // Always capture the latest window size so it can be applied
+ // to the picker when it is built after loading completes.
+ if wsm, ok := msg.(tea.WindowSizeMsg); ok {
+ fp.lastSize = &wsm
+ }
+
switch msg := msg.(type) {
case tea.KeyPressMsg:
if msg.Code == tea.KeyEscape {
@@ -199,12 +208,19 @@ func (fp *FilePicker) updateNotice(msg tea.Msg) (ui.Screen, tea.Cmd) {
}
// buildPicker constructs the picker model from the loaded nodes.
+// If a WindowSizeMsg was received during loading, it is applied
+// to the picker immediately so it has correct dimensions.
func (fp *FilePicker) buildPicker(nodes []restic.LsNode) {
sfs := restic.NewSnapshotFS(nodes)
p := picker.New(sfs)
p.Cursor = strings.TrimSuffix(theme.Cursor, " ")
p.Styles = fp.styles.Picker
fp.picker = &p
+
+ if fp.lastSize != nil {
+ fp.picker.AutoHeight = false
+ fp.picker.SetHeight(max(1, fp.lastSize.Height))
+ }
}
// resolveSelection reads the picker's selection state and converts