fix: Make --select-if-one print to stdout (#463)

For some reason it wasn't printing to stdout (and I could repro that
bug even on versions before I added the newline). It was only showing
up on other streams in the shell (error stream probably), not getting
sent into pipes.

I changed it to fmt.Println.

As for the ansi-stripping that was in `filter`, LMK if that's what you
prefer and I'll add it to `choose` too. I just wanted them to match.
This commit is contained in:
snan 2023-12-10 19:52:11 +01:00 committed by GitHub
parent d1145b4163
commit a11d1ff648
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 8 deletions

View file

@ -34,8 +34,7 @@ func (o Options) Run() error {
}
if o.SelectIfOne && len(o.Options) == 1 {
print(o.Options[0])
print("\n")
fmt.Println(o.Options[0])
return nil
}

View file

@ -44,12 +44,7 @@ func (o Options) Run() error {
}
if o.SelectIfOne && len(o.Options) == 1 {
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Print(o.Options[0])
} else {
fmt.Print(ansi.Strip(o.Options[0]))
}
print("\n")
fmt.Println(o.Options[0])
return nil
}