mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
ex_getln: Check prev_prompt_errors before running redrawcmdline
Otherwise there will be infinite recursion and shortly a crash. Running redrawcmdline recursively occurs under color_cmdline_error label.
This commit is contained in:
parent
cfb1d937a6
commit
8a581b918b
@ -2364,6 +2364,12 @@ static bool color_cmdline(void)
|
|||||||
bool dgc_ret = true;
|
bool dgc_ret = true;
|
||||||
bool tl_ret = true;
|
bool tl_ret = true;
|
||||||
|
|
||||||
|
if (ccline.prompt_id != prev_prompt_id) {
|
||||||
|
prev_prompt_errors = 0;
|
||||||
|
prev_prompt_id = ccline.prompt_id;
|
||||||
|
} else if (prev_prompt_errors >= MAX_CB_ERRORS) {
|
||||||
|
goto color_cmdline_end;
|
||||||
|
}
|
||||||
if (ccline.highlight_callback.type != kCallbackNone) {
|
if (ccline.highlight_callback.type != kCallbackNone) {
|
||||||
// Currently this should only happen while processing input() prompts.
|
// Currently this should only happen while processing input() prompts.
|
||||||
assert(ccline.input_fn);
|
assert(ccline.input_fn);
|
||||||
@ -2392,12 +2398,6 @@ static bool color_cmdline(void)
|
|||||||
if (color_cb.type == kCallbackNone) {
|
if (color_cb.type == kCallbackNone) {
|
||||||
goto color_cmdline_end;
|
goto color_cmdline_end;
|
||||||
}
|
}
|
||||||
if (ccline.prompt_id != prev_prompt_id) {
|
|
||||||
prev_prompt_errors = 0;
|
|
||||||
prev_prompt_id = ccline.prompt_id;
|
|
||||||
} else if (prev_prompt_errors >= MAX_CB_ERRORS) {
|
|
||||||
goto color_cmdline_end;
|
|
||||||
}
|
|
||||||
if (ccline.cmdbuff[ccline.cmdlen] != NUL) {
|
if (ccline.cmdbuff[ccline.cmdlen] != NUL) {
|
||||||
arg_allocated = true;
|
arg_allocated = true;
|
||||||
arg.vval.v_string = xmemdupz((const char *)ccline.cmdbuff,
|
arg.vval.v_string = xmemdupz((const char *)ccline.cmdbuff,
|
||||||
|
@ -527,6 +527,22 @@ describe('Ex commands coloring support', function()
|
|||||||
eq('\nError detected while processing :\nE605: Exception not caught: 42',
|
eq('\nError detected while processing :\nE605: Exception not caught: 42',
|
||||||
meths.command_output('messages'))
|
meths.command_output('messages'))
|
||||||
end)
|
end)
|
||||||
|
it('errors out when failing to get callback', function()
|
||||||
|
meths.set_var('Nvim_color_cmdline', 42)
|
||||||
|
feed(':#')
|
||||||
|
screen:expect([[
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
: |
|
||||||
|
{ERR:E5408: Unable to get Nvim_color_cmdline }|
|
||||||
|
{ERR:callback from g:: Vim:E6000: Argument is}|
|
||||||
|
{ERR: not a function or function name} |
|
||||||
|
:#^ |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
describe('Expressions coloring support', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- TODO Specifically test for coloring in cmdline and expr modes
|
-- TODO Specifically test for coloring in cmdline and expr modes
|
||||||
|
Loading…
Reference in New Issue
Block a user