mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(api): use a conditional stack for nvim_cmd (#26341)
This commit is contained in:
parent
0bbe8e7fc2
commit
130cb4815a
@ -1711,6 +1711,9 @@ int execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo, bool preview)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cstack_T cstack = { .cs_idx = -1 };
|
||||||
|
eap->cstack = &cstack;
|
||||||
|
|
||||||
// Execute the command
|
// Execute the command
|
||||||
execute_cmd0(&retv, eap, &errormsg, preview);
|
execute_cmd0(&retv, eap, &errormsg, preview);
|
||||||
|
|
||||||
|
@ -4547,5 +4547,24 @@ describe('API', function()
|
|||||||
ok(luv.now() - start <= 300)
|
ok(luv.now() - start <= 300)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
it(':call with unknown function does not crash #26289', function()
|
||||||
|
eq('Vim:E117: Unknown function: UnknownFunc',
|
||||||
|
pcall_err(meths.cmd, {cmd = 'call', args = {'UnknownFunc()'}}, {}))
|
||||||
|
end)
|
||||||
|
it(':throw does not crash #24556', function()
|
||||||
|
eq('42', pcall_err(meths.cmd, {cmd = 'throw', args = {'42'}}, {}))
|
||||||
|
end)
|
||||||
|
it('can use :return #24556', function()
|
||||||
|
exec([[
|
||||||
|
func Foo()
|
||||||
|
let g:pos = 'before'
|
||||||
|
call nvim_cmd({'cmd': 'return', 'args': ['[1, 2, 3]']}, {})
|
||||||
|
let g:pos = 'after'
|
||||||
|
endfunc
|
||||||
|
let g:result = Foo()
|
||||||
|
]])
|
||||||
|
eq('before', meths.get_var('pos'))
|
||||||
|
eq({1, 2, 3}, meths.get_var('result'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user