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)
|
table.insert(cmd, filepath)
|
||||||
local out = utils.io_system(cmd)
|
local out = utils.io_system(cmd)
|
||||||
if not utils.shell_error() then
|
if not utils.shell_error() then
|
||||||
line = out:match("[^:]+")
|
line = tonumber(out:match("[^:]+")) or 1
|
||||||
else
|
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
|
end
|
||||||
-- if line == 1 then print(cmd) end
|
-- if line == 1 then print(cmd) end
|
||||||
return line
|
return line
|
||||||
|
@ -292,13 +292,21 @@ end
|
|||||||
|
|
||||||
function FzfWin:check_exit_status(exit_code)
|
function FzfWin:check_exit_status(exit_code)
|
||||||
if not self:validate() then return end
|
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)
|
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)
|
-- the reason we're not ignoring error 1 is due
|
||||||
if not exit_code and (not lines or #lines[1]==0) then return end
|
-- to skim returning 1 for unexpected arguments
|
||||||
utils.warn(("fzf error %s: %s")
|
-- only warn about there is an actual error msg
|
||||||
:format(exit_code or "<null>",
|
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>"))
|
lines and #lines[1]>0 and lines[1] or "<null>"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user