diff --git a/lua/fzf-lua/core.lua b/lua/fzf-lua/core.lua index 46b06e0..def924e 100644 --- a/lua/fzf-lua/core.lua +++ b/lua/fzf-lua/core.lua @@ -40,9 +40,9 @@ M.fzf = function(opts, contents) fzf_win:attach_previewer(previewer) fzf_win:create() - local selected = fzf.raw_fzf(contents, M.build_fzf_cli(opts), + local selected, exit_code = fzf.raw_fzf(contents, M.build_fzf_cli(opts), { fzf_binary = opts.fzf_bin, fzf_cwd = opts.cwd }) - fzf_win:check_exit_status() + fzf_win:check_exit_status(exit_code) if fzf_win:autoclose() == nil or fzf_win:autoclose() then fzf_win:close() end diff --git a/lua/fzf-lua/win.lua b/lua/fzf-lua/win.lua index 1af1bdb..c6866c9 100644 --- a/lua/fzf-lua/win.lua +++ b/lua/fzf-lua/win.lua @@ -202,11 +202,15 @@ function FzfWin:reset_win_highlights(win, is_border) vim.api.nvim_win_set_option(win, 'winhighlight', hl) end -function FzfWin:check_exit_status() +function FzfWin:check_exit_status(exit_code) if not self:validate() then return end - local lines = vim.api.nvim_buf_get_lines(self.fzf_bufnr, 0, 1, false) - if lines and #lines[1]>0 then - utils.warn("fzf error: " .. lines[1]) + if not exit_code or tonumber(exit_code) ~= 130 then + local lines = vim.api.nvim_buf_get_lines(self.fzf_bufnr, 0, 1, false) + -- this can happen before nvim-fzf returned exit code (PR #36) + if not exit_code and (not lines or #lines[1]==0) then return end + utils.warn(("fzf error %s: %s") + :format(exit_code or "", + lines and #lines[1]>0 and lines[1] or "")) end end