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),