From 29d27966922ccf0e4ce904d494da997899760b86 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 23 Nov 2025 11:02:33 +0530 Subject: [PATCH] Fix output format not being respected for STDOUT --- kittens/choose_files/main.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/kittens/choose_files/main.go b/kittens/choose_files/main.go index c005832f5..28f2b9b01 100644 --- a/kittens/choose_files/main.go +++ b/kittens/choose_files/main.go @@ -315,6 +315,7 @@ func (h *Handler) OnInitialize() (ans string, err error) { err = h.graphics_handler.Initialize(h.lp) h.result_manager.set_root_dir() h.draw_screen() + h.lp.SendOverlayReady() return } @@ -772,16 +773,16 @@ func main(_ *cli.Command, opts *Options, args []string) (rc int, err error) { return } m := strings.Join(selections, "\n") + if opts.OutputFormat == "json" { + payload["paths"] = selections + if current_filter != "" { + payload["current_filter"] = current_filter + } + b, _ := json.MarshalIndent(payload, "", " ") + m = string(b) + } fmt.Print(m) if opts.WriteOutputTo != "" { - if opts.OutputFormat == "json" { - payload["paths"] = selections - if current_filter != "" { - payload["current_filter"] = current_filter - } - b, _ := json.MarshalIndent(payload, "", " ") - m = string(b) - } os.WriteFile(opts.WriteOutputTo, []byte(m), 0600) } }