From a1b2e7dcd1fa307fb9dd2f4df8dc7c37ed709971 Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Tue, 27 May 2025 20:36:22 +0800 Subject: [PATCH] fix: `nvim -q` --- lua/flatten/core.lua | 5 +++-- lua/flatten/guest.lua | 9 +++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lua/flatten/core.lua b/lua/flatten/core.lua index 5ff3b85..e7388d3 100644 --- a/lua/flatten/core.lua +++ b/lua/flatten/core.lua @@ -212,8 +212,9 @@ function M.edit_files(opts) } end - if quickfix then - vim.fn.setqflist(quickfix, "r") + if quickfix and #quickfix ~= 0 then + vim.fn.setqflist(quickfix, " ") + return false end ---@type Flatten.WindowId diff --git a/lua/flatten/guest.lua b/lua/flatten/guest.lua index 78e6826..068a11d 100644 --- a/lua/flatten/guest.lua +++ b/lua/flatten/guest.lua @@ -144,13 +144,10 @@ function M.init(host_pipe) :totable() nfiles = #files - local quickfix = vim.iter(vim.api.nvim_list_bufs()):find(function(buf) - return vim.bo[buf].filetype == "quickfix" - end) - + local quickfix = vim.fn.getqflist() -- No arguments, user is probably opening a nested session intentionally -- Or only piping input from stdin - if nfiles < 1 and not quickfix then + if nfiles < 1 and #quickfix == 0 then local should_nest, should_block = config.nest_if_no_args, false if config.hooks.no_files then @@ -179,7 +176,7 @@ function M.init(host_pipe) end quickfix = vim - .iter(vim.fn.getqflist()) + .iter(quickfix) :map(function(old) return { filename = vim.api.nvim_buf_get_name(old.bufnr),