From 7ff2fec04a5d1408a015aca089219cbd2fe7ce17 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 16 Apr 2024 14:55:26 +0800 Subject: [PATCH] fix(job): check cmd before run job --- lua/spacevim/api/job.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/spacevim/api/job.lua b/lua/spacevim/api/job.lua index b152dd412..ee0ff4e12 100644 --- a/lua/spacevim/api/job.lua +++ b/lua/spacevim/api/job.lua @@ -79,6 +79,9 @@ function M.start(cmd, opts) local command = '' local argv = {} if type(cmd) == 'string' then + if cmd == '' then + return 0 + end local shell = vim.fn.split(vim.o.shell) local shellcmdflag = vim.fn.split(vim.o.shellcmdflag) -- :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}']) @@ -89,7 +92,15 @@ function M.start(cmd, opts) end table.insert(argv, cmd) elseif type(cmd) == 'table' then + for _, v in ipairs(cmd) do + if type(v) ~= 'string' then + return 0 + end + end command = cmd[1] + if command == '' then + return 0 + end if vim.fn.executable(command) == 0 then return -1 end