mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
lua: do not crash on syntax error in debug.debug()
This commit is contained in:
parent
d3a7bdefb0
commit
e6d77993d1
@ -449,11 +449,10 @@ int nlua_debug(lua_State *lstate)
|
||||
if (luaL_loadbuffer(lstate, (const char *)input.vval.v_string,
|
||||
STRLEN(input.vval.v_string), "=(debug command)")) {
|
||||
nlua_error(lstate, _("E5115: Error while loading debug string: %.*s"));
|
||||
}
|
||||
tv_clear(&input);
|
||||
if (lua_pcall(lstate, 0, 0, 0)) {
|
||||
} else if (lua_pcall(lstate, 0, 0, 0)) {
|
||||
nlua_error(lstate, _("E5116: Error while calling debug string: %.*s"));
|
||||
}
|
||||
tv_clear(&input);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -207,6 +207,81 @@ describe('debug.debug', function()
|
||||
{cr:Press ENTER or type command to continue}^ |
|
||||
]])
|
||||
end)
|
||||
|
||||
it("can be safely exited with 'cont'", function()
|
||||
feed('<cr>')
|
||||
feed(':lua debug.debug() print("x")<cr>')
|
||||
screen:expect{grid=[[
|
||||
|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
lua_debug> ^ |
|
||||
]]}
|
||||
|
||||
feed("conttt<cr>") -- misspelled cont; invalid syntax
|
||||
screen:expect{grid=[[
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
lua_debug> conttt |
|
||||
{E:E5115: Error while loading debug string: (debug comma}|
|
||||
{E:nd):1: '=' expected near '<eof>'} |
|
||||
lua_debug> ^ |
|
||||
]]}
|
||||
|
||||
feed("cont<cr>") -- exactly "cont", exit now
|
||||
screen:expect{grid=[[
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
lua_debug> conttt |
|
||||
{E:E5115: Error while loading debug string: (debug comma}|
|
||||
{E:nd):1: '=' expected near '<eof>'} |
|
||||
lua_debug> cont |
|
||||
x |
|
||||
{cr:Press ENTER or type command to continue}^ |
|
||||
]]}
|
||||
|
||||
feed('<cr>')
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]]}
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('package.path/package.cpath', function()
|
||||
|
Loading…
Reference in New Issue
Block a user