diff options
author | Maas Lalani <maas@lalani.dev> | 2022-12-13 15:41:01 -0500 |
---|---|---|
committer | Maas Lalani <maas@lalani.dev> | 2022-12-13 15:41:01 -0500 |
commit | c8e6b4a9d5aa4c7a8d8018584d32bfde45c1dbdf (patch) | |
tree | 81350676d75deea6473bea4083591a39cb95b81a | |
parent | 7756c809d1146ff97817bc1ace6f8a4d094add9c (diff) |
fix: trim only trailing newline, space may be intentional
-rw-r--r-- | choose/command.go | 2 | ||||
-rw-r--r-- | filter/command.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/choose/command.go b/choose/command.go index ca39855..6dd6b99 100644 --- a/choose/command.go +++ b/choose/command.go @@ -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. diff --git a/filter/command.go b/filter/command.go index 5cb3cfd..7f12e30 100644 --- a/filter/command.go +++ b/filter/command.go @@ -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") } |