From a11d1ff648959d8354a0bcb78366bb78492d6b2e Mon Sep 17 00:00:00 2001 From: snan Date: Sun, 10 Dec 2023 19:52:11 +0100 Subject: [PATCH] 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. --- choose/command.go | 3 +-- filter/command.go | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/choose/command.go b/choose/command.go index ede9338ec..66691d83a 100644 --- a/choose/command.go +++ b/choose/command.go @@ -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 } diff --git a/filter/command.go b/filter/command.go index 95569b2e4..f4af7193a 100644 --- a/filter/command.go +++ b/filter/command.go @@ -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 }