mirror of
https://github.com/charmbracelet/gum.git
synced 2024-07-07 02:46:29 +03:00
fix(stdin): add trim of trailing newline (#577)
* stdin: add trim of trailing newline * choose: remove trimsuffix * filter: remove trimsuffix * style: remove trimsuffix
This commit is contained in:
parent
26178f8894
commit
2fe0291e02
|
@ -22,7 +22,7 @@ func (o Options) Run() error {
|
|||
if input == "" {
|
||||
return errors.New("no options provided, see `gum choose --help`")
|
||||
}
|
||||
o.Options = strings.Split(strings.TrimSuffix(input, "\n"), "\n")
|
||||
o.Options = strings.Split(input, "\n")
|
||||
}
|
||||
|
||||
if o.SelectIfOne && len(o.Options) == 1 {
|
||||
|
|
|
@ -34,7 +34,7 @@ func (o Options) Run() error {
|
|||
|
||||
if len(o.Options) == 0 {
|
||||
if input, _ := stdin.Read(); input != "" {
|
||||
o.Options = strings.Split(strings.TrimSuffix(input, "\n"), "\n")
|
||||
o.Options = strings.Split(input, "\n")
|
||||
} else {
|
||||
o.Options = files.List()
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ func Read() (string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
return b.String(), nil
|
||||
return strings.TrimSuffix(b.String(), "\n"), nil
|
||||
}
|
||||
|
||||
// IsEmpty returns whether stdin is empty.
|
||||
|
|
|
@ -24,7 +24,6 @@ func (o Options) Run() error {
|
|||
if text == "" {
|
||||
return errors.New("no input provided, see `gum style --help`")
|
||||
}
|
||||
text = strings.TrimSuffix(text, "\n")
|
||||
}
|
||||
fmt.Println(o.Style.ToLipgloss().Render(text))
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue
Block a user