fix: wrap vim.cmd in pcall to avoid error (#1247)

When opening a file under swap from the "fd" finder results an error was
printed after the file was opened, wrapping the call to "vim.cmd" in a
pcall avoids the error.
This commit is contained in:
gavynriebau
2021-09-16 18:02:24 +08:00
committed by GitHub
parent 5f0ccf1346
commit ac03f495c6

View File

@@ -131,7 +131,7 @@ action_set.edit = function(prompt_bufnr, command)
-- prevents restarting lsp server -- prevents restarting lsp server
if vim.api.nvim_buf_get_name(0) ~= filename or command ~= "edit" then if vim.api.nvim_buf_get_name(0) ~= filename or command ~= "edit" then
filename = Path:new(vim.fn.fnameescape(filename)):normalize(vim.loop.cwd()) filename = Path:new(vim.fn.fnameescape(filename)):normalize(vim.loop.cwd())
vim.cmd(string.format("%s %s", command, filename)) pcall(vim.cmd, string.format("%s %s", command, filename))
end end
end end