aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/api/private/helpers.c9
-rw-r--r--src/nvim/api/private/helpers.h3
-rw-r--r--src/nvim/ex_eval.c2
-rw-r--r--src/nvim/ex_getln.c3
4 files changed, 14 insertions, 3 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index a04cc9a312..6ff56709cd 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -49,13 +49,17 @@ void try_enter(TryState *const tstate)
.trylevel = trylevel,
.got_int = got_int,
.did_throw = did_throw,
+ .need_rethrow = need_rethrow,
+ .current_exception = current_exception,
.msg_list = (const struct msglist *const *)msg_list,
.private_msg_list = NULL,
};
trylevel = 1;
got_int = false;
did_throw = false;
+ need_rethrow = false;
msg_list = &tstate->private_msg_list;
+ current_exception = NULL;
}
/// End try block, set the error message if any and restore previous state
@@ -72,14 +76,17 @@ bool try_leave(const TryState *const tstate, Error *const err)
{
const bool ret = !try_end(err);
assert(trylevel == 0);
+ assert(!need_rethrow);
assert(!got_int);
assert(!did_throw);
assert(msg_list == &tstate->private_msg_list);
assert(*msg_list == NULL);
+ assert(current_exception == NULL);
trylevel = tstate->trylevel;
got_int = tstate->got_int;
did_throw = tstate->did_throw;
msg_list = (struct msglist **)tstate->msg_list;
+ current_exception = tstate->current_exception;
return ret;
}
@@ -96,6 +103,8 @@ void try_start(void)
/// @return true if an error occurred
bool try_end(Error *err)
{
+ // Note: all globals manipulated here should be saved/restored in
+ // try_enter/try_leave.
--trylevel;
// Without this it stops processing all subsequent VimL commands and
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 112d785bfd..0b2cf883a6 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -6,6 +6,7 @@
#include "nvim/api/private/defs.h"
#include "nvim/vim.h"
#include "nvim/memory.h"
+#include "nvim/ex_eval.h"
#include "nvim/lib/kvec.h"
#define OBJECT_OBJ(o) o
@@ -90,6 +91,8 @@ typedef struct {
int trylevel;
int got_int;
int did_throw;
+ int need_rethrow;
+ except_T *current_exception;
struct msglist *private_msg_list;
const struct msglist *const *msg_list;
} TryState;
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index 5d664b94a8..139305998d 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -565,6 +565,8 @@ static void discard_exception(except_T *excp, int was_finished)
void discard_current_exception(void)
{
discard_exception(current_exception, FALSE);
+ // Note: all globals manipulated here should be saved/restored in
+ // try_enter/try_leave.
current_exception = NULL;
did_throw = FALSE;
need_rethrow = FALSE;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 6c61e30f3d..275e1b7fdd 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2341,8 +2341,6 @@ static bool color_cmdline(void)
return ret;
}
- const int saved_force_abort = force_abort;
- force_abort = true;
bool arg_allocated = false;
typval_T arg = {
.v_type = VAR_STRING,
@@ -2504,7 +2502,6 @@ color_cmdline_end:
if (can_free_cb) {
callback_free(&color_cb);
}
- force_abort = saved_force_abort;
if (arg_allocated) {
tv_clear(&arg);
}