mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
api helpers: Also save and restore did_emsg
This commit is contained in:
parent
3a923ad2db
commit
cfb1d937a6
@ -46,20 +46,22 @@ typedef struct {
|
|||||||
void try_enter(TryState *const tstate)
|
void try_enter(TryState *const tstate)
|
||||||
{
|
{
|
||||||
*tstate = (TryState) {
|
*tstate = (TryState) {
|
||||||
|
.current_exception = current_exception,
|
||||||
|
.msg_list = (const struct msglist *const *)msg_list,
|
||||||
|
.private_msg_list = NULL,
|
||||||
.trylevel = trylevel,
|
.trylevel = trylevel,
|
||||||
.got_int = got_int,
|
.got_int = got_int,
|
||||||
.did_throw = did_throw,
|
.did_throw = did_throw,
|
||||||
.need_rethrow = need_rethrow,
|
.need_rethrow = need_rethrow,
|
||||||
.current_exception = current_exception,
|
.did_emsg = did_emsg,
|
||||||
.msg_list = (const struct msglist *const *)msg_list,
|
|
||||||
.private_msg_list = NULL,
|
|
||||||
};
|
};
|
||||||
|
msg_list = &tstate->private_msg_list;
|
||||||
|
current_exception = NULL;
|
||||||
trylevel = 1;
|
trylevel = 1;
|
||||||
got_int = false;
|
got_int = false;
|
||||||
did_throw = false;
|
did_throw = false;
|
||||||
need_rethrow = false;
|
need_rethrow = false;
|
||||||
msg_list = &tstate->private_msg_list;
|
did_emsg = false;
|
||||||
current_exception = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// End try block, set the error message if any and restore previous state
|
/// End try block, set the error message if any and restore previous state
|
||||||
@ -79,14 +81,17 @@ bool try_leave(const TryState *const tstate, Error *const err)
|
|||||||
assert(!need_rethrow);
|
assert(!need_rethrow);
|
||||||
assert(!got_int);
|
assert(!got_int);
|
||||||
assert(!did_throw);
|
assert(!did_throw);
|
||||||
|
assert(!did_emsg);
|
||||||
assert(msg_list == &tstate->private_msg_list);
|
assert(msg_list == &tstate->private_msg_list);
|
||||||
assert(*msg_list == NULL);
|
assert(*msg_list == NULL);
|
||||||
assert(current_exception == NULL);
|
assert(current_exception == NULL);
|
||||||
|
msg_list = (struct msglist **)tstate->msg_list;
|
||||||
|
current_exception = tstate->current_exception;
|
||||||
trylevel = tstate->trylevel;
|
trylevel = tstate->trylevel;
|
||||||
got_int = tstate->got_int;
|
got_int = tstate->got_int;
|
||||||
did_throw = tstate->did_throw;
|
did_throw = tstate->did_throw;
|
||||||
msg_list = (struct msglist **)tstate->msg_list;
|
need_rethrow = tstate->need_rethrow;
|
||||||
current_exception = tstate->current_exception;
|
did_emsg = tstate->did_emsg;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,13 +88,14 @@
|
|||||||
/// Used when caller is supposed to be operating when other VimL code is being
|
/// Used when caller is supposed to be operating when other VimL code is being
|
||||||
/// processed and that “other VimL code” must not be affected.
|
/// processed and that “other VimL code” must not be affected.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
except_T *current_exception;
|
||||||
|
struct msglist *private_msg_list;
|
||||||
|
const struct msglist *const *msg_list;
|
||||||
int trylevel;
|
int trylevel;
|
||||||
int got_int;
|
int got_int;
|
||||||
int did_throw;
|
int did_throw;
|
||||||
int need_rethrow;
|
int need_rethrow;
|
||||||
except_T *current_exception;
|
int did_emsg;
|
||||||
struct msglist *private_msg_list;
|
|
||||||
const struct msglist *const *msg_list;
|
|
||||||
} TryState;
|
} TryState;
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
|
@ -489,6 +489,44 @@ describe('Ex commands coloring support', function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
it('does not prevent mapping error from cancelling prompt', function()
|
||||||
|
meths.command("cnoremap <expr> x execute('throw 42')[-1]")
|
||||||
|
feed(':#x')
|
||||||
|
screen:expect([[
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
:# |
|
||||||
|
{ERR:Error detected while processing :} |
|
||||||
|
{ERR:E605: Exception not caught: 42} |
|
||||||
|
:#^ |
|
||||||
|
]])
|
||||||
|
feed('<CR>')
|
||||||
|
screen:expect([[
|
||||||
|
^ |
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
feed('<CR>')
|
||||||
|
screen:expect([[
|
||||||
|
^ |
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
{EOB:~ }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
eq('\nError detected while processing :\nE605: Exception not caught: 42',
|
||||||
|
meths.command_output('messages'))
|
||||||
|
end)
|
||||||
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