suppress exit code 1 error msg, better warning for non-matched tags
This commit is contained in:
parent
84fa52720c
commit
d55db75d1a
@ -157,9 +157,9 @@ local grep_tag = function(file, tag)
|
||||
table.insert(cmd, filepath)
|
||||
local out = utils.io_system(cmd)
|
||||
if not utils.shell_error() then
|
||||
line = out:match("[^:]+")
|
||||
line = tonumber(out:match("[^:]+")) or 1
|
||||
else
|
||||
utils.warn(("Unable to find pattern '%s' in file '%s'"):format(pattern, file))
|
||||
utils.warn(("previewer: unable to find pattern '%s' in file '%s'"):format(pattern, file))
|
||||
end
|
||||
-- if line == 1 then print(cmd) end
|
||||
return line
|
||||
|
@ -292,15 +292,23 @@ end
|
||||
|
||||
function FzfWin:check_exit_status(exit_code)
|
||||
if not self:validate() then return end
|
||||
if not exit_code or (exit_code ~=0 and exit_code ~= 130) then
|
||||
-- from 'man fzf':
|
||||
-- 0 Normal exit
|
||||
-- 1 No match
|
||||
-- 2 Error
|
||||
-- 130 Interrupted with CTRL-C or ESC
|
||||
if exit_code ~=0 and 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 "<null>",
|
||||
-- the reason we're not ignoring error 1 is due
|
||||
-- to skim returning 1 for unexpected arguments
|
||||
-- only warn about there is an actual error msg
|
||||
if exit_code ~= 1 or (lines and #lines[1]>0) then
|
||||
utils.warn(("fzf error %s: %s"):format(
|
||||
exit_code or "<null>",
|
||||
lines and #lines[1]>0 and lines[1] or "<null>"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function FzfWin:_set_autoclose(autoclose)
|
||||
if autoclose ~= nil then
|
||||
|
Loading…
Reference in New Issue
Block a user