Skip to content

Commit

Permalink
fix: Make --select-if-one print to stdout (#463)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
snan authored Dec 10, 2023
1 parent d1145b4 commit a11d1ff
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
3 changes: 1 addition & 2 deletions choose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
7 changes: 1 addition & 6 deletions filter/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit a11d1ff

Please sign in to comment.