fix: trim only trailing newline, space may be intentional

This commit is contained in:
Maas Lalani 2022-12-13 15:41:01 -05:00
parent 7756c809d1
commit c8e6b4a9d5
No known key found for this signature in database
GPG key ID: 5A6ED5CBF1A0A000
2 changed files with 2 additions and 2 deletions

View file

@ -29,7 +29,7 @@ func (o Options) Run() error {
if input == "" {
return errors.New("no options provided, see `gum choose --help`")
}
o.Options = strings.Split(strings.TrimSpace(input), "\n")
o.Options = strings.Split(strings.TrimSuffix(input, "\n"), "\n")
}
// We don't need to display prefixes if we are only picking one option.

View file

@ -33,7 +33,7 @@ func (o Options) Run() error {
var choices []string
if input, _ := stdin.Read(); input != "" {
input = strings.TrimSpace(input)
input = strings.TrimSuffix(input, "\n")
if input != "" {
choices = strings.Split(input, "\n")
}