charmbracelet / huh

Build terminal forms and prompts 🤷🏻‍♀️
MIT License
3.72k stars 94 forks source link

Fullscreen / AltScreen does not take the full screen - there seems to be a maximum height #275

Open jbcpollak opened 1 month ago

jbcpollak commented 1 month ago

In AltScreen mode, I was expecting huh to display as much of the form as would fit on screen and be continuously responsive to changing sizes of the terminal window. If the terminal window is larger than the form, I would expect the rest of the window to be empty.

Using the main branch of Huh, I modified the scroll example to be:

func main() {
    form := huh.NewForm(
        huh.NewGroup(
            huh.NewInput().Title("First"),
            huh.NewInput().Title("Second"),
            huh.NewInput().Title("Third"),
            huh.NewInput().Title("Fourth"),
            huh.NewInput().Title("Fifth"),
            huh.NewInput().Title("Sixth"),
            huh.NewInput().Title("Seventh"),
            huh.NewInput().Title("Eigth"),
            huh.NewInput().Title("Nineth"),
            huh.NewInput().Title("Tenth"),
        ),
    ).WithProgramOptions(tea.WithAltScreen())
    form.Run()

When the terminal is less than the maximum height of the form, everything is fine and it scrolls normally.

If I expand the terminal, I see the following:

Screenshot 2024-06-06 at 2 30 02 PM

I would have expected the form to expand to fill the screen.

If I shrink and the re-expand the terminal slowly, I can see more of the form, but not as much as could fit:

Screenshot 2024-06-06 at 2 31 23 PM

The behavior seems to be inconsistent and not as I would intuitively expect.