charmbracelet / gum

A tool for glamorous shell scripts 🎀
MIT License
17.94k stars 339 forks source link

gum input header flags can output an incorrect render #582

Closed ndsizeif closed 1 month ago

ndsizeif commented 4 months ago

Describe the bug Setting some of the header properties of gum input including, --header.align and --header.height, can cause rendering over subsequent lines of the output.

To Reproduce This simple bash script sets a header and aligns it inside a border.

#!/bin/bash

term_width=$(tput cols)
WIDTH=$((term_width / 2))

gum input \
    --header="example header" \
    --header.width=$WIDTH \
    --header.align="center" \
    --header.border="thick"

border14 0

Using a border makes the behavior apparent, but output is also affected without a border. Setting header height to more than 2 obscures the placeholder.

gum input \
    --header="example header" \
    --header.height="4"

height14 0

Expected behavior The above commands should render as they do using gum v0.13.0

border13 0

height13 0

gum version 0.14.0 (295a671)

Description:    Manjaro Linux
Release:        24.0.0
Codename:       Wynsdey
caarlos0 commented 2 months ago

this should be fixed by #634

ndsizeif commented 1 month ago

Thanks for working on this @caarlos0.

I just wanted to report behavior of some scripts using commit 96448e0

The scripts without any type of border now work as expected. Thanks for the fix.

gum input \
    --header="example header"

The scripts with a border will have the input line obscured

gum input \
    --header="example header"
    --header.border="thick"

gum v0.13.0 gum13 96448e0 gum14

caarlos0 commented 1 month ago

good find, seems to be related to the height, not sure how yet, though

caarlos0 commented 1 month ago

should be fixed on main!