fix(system-open): use notify for system-open failures and tidy messages

This commit is contained in:
Alexander Courtis
2022-11-15 13:01:15 +11:00
parent cf908370fb
commit 9d241e5f58

View File

@@ -1,3 +1,5 @@
local notify = require "nvim-tree.notify"
local M = { local M = {
config = { config = {
is_windows = vim.fn.has "win32" == 1 or vim.fn.has "win32unix" == 1, is_windows = vim.fn.has "win32" == 1 or vim.fn.has "win32unix" == 1,
@@ -27,14 +29,13 @@ function M.fn(node)
process.stderr:close() process.stderr:close()
process.handle:close() process.handle:close()
if code ~= 0 then if code ~= 0 then
process.errors = process.errors .. string.format("NvimTree system_open: return code %d.", code) notify.warn(string.format("system_open failed with return code %d: %s", code, process.errors))
error(process.errors)
end end
end end
) )
table.remove(process.args) table.remove(process.args)
if not process.handle then if not process.handle then
error("\n" .. process.pid .. "\nNvimTree system_open: failed to spawn process using '" .. process.cmd .. "'.") notify.warn(string.format("system_open failed to spawn command '%s': %s", process.cmd, process.pid))
return return
end end
vim.loop.read_start(process.stderr, function(err, data) vim.loop.read_start(process.stderr, function(err, data)