ex_getln: Make sure standard error reporting facility is not used

This commit is contained in:
ZyX 2017-06-28 22:20:47 +03:00
parent 3da49cd68e
commit 99079a164d

View File

@ -2227,24 +2227,30 @@ static bool color_cmdline(void)
Callback color_cb = { .type = kCallbackNone }; Callback color_cb = { .type = kCallbackNone };
bool can_free_cb = false; bool can_free_cb = false;
Error err = ERROR_INIT; Error err = ERROR_INIT;
const char *err_errmsg = (const char *)e_intern2;
bool dgc_ret = true;
try_start();
if (ccline.input_fn) { if (ccline.input_fn) {
color_cb = getln_input_callback; color_cb = getln_input_callback;
} else if (ccline.cmdfirstc == ':') { } else if (ccline.cmdfirstc == ':') {
if (!tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_cmdline"), err_errmsg = N_(
&color_cb)) { "E5408: Unable to get Nvim_color_cmdline callback from g:: %s");
goto color_cmdline_error; dgc_ret = tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_cmdline"),
} &color_cb);
can_free_cb = true; can_free_cb = true;
} else if (ccline.cmdfirstc == '=') { } else if (ccline.cmdfirstc == '=') {
if (!tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_expr"), err_errmsg = N_(
&color_cb)) { "E5409: Unable to get Nvim_color_expr callback from g:: %s");
goto color_cmdline_error; dgc_ret = tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_expr"),
} &color_cb);
can_free_cb = true; can_free_cb = true;
} else { } else {
goto color_cmdline_end; goto color_cmdline_end;
} }
if (try_end(&err) || !dgc_ret) {
goto color_cmdline_error;
}
if (color_cb.type == kCallbackNone) { if (color_cb.type == kCallbackNone) {
goto color_cmdline_end; goto color_cmdline_end;
@ -2273,6 +2279,7 @@ static bool color_cmdline(void)
// Also using try_start() because error messages may overwrite typed // Also using try_start() because error messages may overwrite typed
// command-line which is not expected. // command-line which is not expected.
try_start(); try_start();
err_errmsg = N_("E5407: Callback has thrown an exception: %s");
const int saved_msg_col = msg_col; const int saved_msg_col = msg_col;
msg_silent++; msg_silent++;
const bool cbcall_ret = callback_call(&color_cb, 1, &arg, &tv); const bool cbcall_ret = callback_call(&color_cb, 1, &arg, &tv);
@ -2372,7 +2379,7 @@ color_cmdline_end:
return ret; return ret;
color_cmdline_error: color_cmdline_error:
if (ERROR_SET(&err)) { if (ERROR_SET(&err)) {
PRINT_ERRMSG(_("E5407: Callback has thrown an exception: %s"), err.msg); PRINT_ERRMSG(_(err_errmsg), err.msg);
api_clear_error(&err); api_clear_error(&err);
} }
assert(printed_errmsg); assert(printed_errmsg);