diff --git a/lua/rustaceanvim/compat.lua b/lua/rustaceanvim/compat.lua index 89596003..19bd8a9f 100644 --- a/lua/rustaceanvim/compat.lua +++ b/lua/rustaceanvim/compat.lua @@ -20,7 +20,7 @@ M.uv = vim.uv or vim.loop M.system = vim.system -- wrapper around vim.fn.system to give it a similar API to vim.system or function(cmd, opts, on_exit) - if opts.cwd then + if opts and opts.cwd then local shell = require('rustaceanvim.shell') cmd = shell.chain_commands { 'cd ' .. opts.cwd, table.concat(cmd, ' ') } ---@cast cmd string @@ -35,7 +35,9 @@ M.system = vim.system stderr = not ok and (output or '') or nil, code = vim.v.shell_error, } - on_exit(systemObj) + if on_exit then + on_exit(systemObj) + end return systemObj end