aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_eval.c
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-08-19 12:26:08 -0600
committerJosh Rahm <rahm@google.com>2022-08-19 13:06:41 -0600
commita7237662f96933efe29eed8212464571e3778cd0 (patch)
tree27930202726b4251437c8cfa53069f65b4db90dc /src/nvim/ex_eval.c
parent02292344929069ea63c0bb872cc22d552d86b67f (diff)
parentb2f979b30beac67906b2dd717fcb6a34f46f5e54 (diff)
downloadrneovim-tmp.tar.gz
rneovim-tmp.tar.bz2
rneovim-tmp.zip
Merge branch 'master' of https://github.com/neovim/neovim into rahmtmp
Diffstat (limited to 'src/nvim/ex_eval.c')
-rw-r--r--src/nvim/ex_eval.c54
1 files changed, 35 insertions, 19 deletions
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index f67c8a6720..69d509abb7 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -16,12 +16,12 @@
#include "nvim/debugger.h"
#include "nvim/eval.h"
#include "nvim/eval/userfunc.h"
-#include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/regexp.h"
+#include "nvim/runtime.h"
#include "nvim/strings.h"
#include "nvim/vim.h"
@@ -151,8 +151,8 @@ int aborted_in_try(void)
bool cause_errthrow(const char *mesg, bool severe, bool *ignore)
FUNC_ATTR_NONNULL_ALL
{
- struct msglist *elem;
- struct msglist **plist;
+ msglist_T *elem;
+ msglist_T **plist;
/*
* Do nothing when displaying the interrupt message or reporting an
@@ -254,7 +254,7 @@ bool cause_errthrow(const char *mesg, bool severe, bool *ignore)
plist = &(*plist)->next;
}
- elem = xmalloc(sizeof(struct msglist));
+ elem = xmalloc(sizeof(msglist_T));
elem->msg = xstrdup(mesg);
elem->next = NULL;
elem->throw_msg = NULL;
@@ -275,20 +275,26 @@ bool cause_errthrow(const char *mesg, bool severe, bool *ignore)
(*msg_list)->throw_msg = tmsg;
}
}
+
+ // Get the source name and lnum now, it may change before
+ // reaching do_errthrow().
+ elem->sfile = estack_sfile(ESTACK_NONE);
+ elem->slnum = SOURCING_LNUM;
}
return true;
}
}
/// Free a "msg_list" and the messages it contains.
-static void free_msglist(struct msglist *l)
+static void free_msglist(msglist_T *l)
{
- struct msglist *messages, *next;
+ msglist_T *messages, *next;
messages = l;
while (messages != NULL) {
next = messages->next;
xfree(messages->msg);
+ xfree(messages->sfile);
xfree(messages);
messages = next;
}
@@ -389,7 +395,7 @@ char *get_exception_string(void *value, except_type_T type, char *cmdname, int *
if (type == ET_ERROR) {
*should_free = true;
- mesg = ((struct msglist *)value)->throw_msg;
+ mesg = ((msglist_T *)value)->throw_msg;
if (cmdname != NULL && *cmdname != NUL) {
size_t cmdlen = STRLEN(cmdname);
ret = xstrnsave("Vim(", 4 + cmdlen + 2 + STRLEN(mesg));
@@ -469,7 +475,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname)
if (type == ET_ERROR) {
// Store the original message and prefix the exception value with
// "Vim:" or, if a command name is given, "Vim(cmdname):".
- excp->messages = (struct msglist *)value;
+ excp->messages = (msglist_T *)value;
}
excp->value = get_exception_string(value, type, cmdname, &should_free);
@@ -478,8 +484,18 @@ static int throw_exception(void *value, except_type_T type, char *cmdname)
}
excp->type = type;
- excp->throw_name = xstrdup(sourcing_name == NULL ? "" : sourcing_name);
- excp->throw_lnum = sourcing_lnum;
+ if (type == ET_ERROR && ((msglist_T *)value)->sfile != NULL) {
+ msglist_T *entry = (msglist_T *)value;
+ excp->throw_name = entry->sfile;
+ entry->sfile = NULL;
+ excp->throw_lnum = entry->slnum;
+ } else {
+ excp->throw_name = estack_sfile(ESTACK_NONE);
+ if (excp->throw_name == NULL) {
+ excp->throw_name = xstrdup("");
+ }
+ excp->throw_lnum = SOURCING_LNUM;
+ }
if (p_verbose >= 13 || debug_break_level > 0) {
int save_msg_silent = msg_silent;
@@ -489,7 +505,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname)
} else {
verbose_enter();
}
- ++no_wait_return;
+ no_wait_return++;
if (debug_break_level > 0 || *p_vfile == NUL) {
msg_scroll = TRUE; // always scroll up, don't overwrite
}
@@ -499,7 +515,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname)
if (debug_break_level > 0 || *p_vfile == NUL) {
cmdline_row = msg_row;
}
- --no_wait_return;
+ no_wait_return--;
if (debug_break_level > 0) {
msg_silent = save_msg_silent;
} else {
@@ -542,7 +558,7 @@ static void discard_exception(except_T *excp, bool was_finished)
} else {
verbose_enter();
}
- ++no_wait_return;
+ no_wait_return++;
if (debug_break_level > 0 || *p_vfile == NUL) {
msg_scroll = TRUE; // always scroll up, don't overwrite
}
@@ -610,7 +626,7 @@ static void catch_exception(except_T *excp)
} else {
verbose_enter();
}
- ++no_wait_return;
+ no_wait_return++;
if (debug_break_level > 0 || *p_vfile == NUL) {
msg_scroll = TRUE; // always scroll up, don't overwrite
}
@@ -620,7 +636,7 @@ static void catch_exception(except_T *excp)
if (debug_break_level > 0 || *p_vfile == NUL) {
cmdline_row = msg_row;
}
- --no_wait_return;
+ no_wait_return--;
if (debug_break_level > 0) {
msg_silent = save_msg_silent;
} else {
@@ -732,12 +748,12 @@ static void report_pending(int action, int pending, void *value)
if (debug_break_level > 0) {
msg_silent = FALSE; // display messages
}
- ++no_wait_return;
- msg_scroll = TRUE; // always scroll up, don't overwrite
+ no_wait_return++;
+ msg_scroll = true; // always scroll up, don't overwrite
smsg(mesg, s);
msg_puts("\n"); // don't overwrite this either
cmdline_row = msg_row;
- --no_wait_return;
+ no_wait_return--;
if (debug_break_level > 0) {
msg_silent = save_msg_silent;
}
@@ -2038,7 +2054,7 @@ int has_loop_cmd(char *p)
// skip modifiers, white space and ':'
for (;;) {
while (*p == ' ' || *p == '\t' || *p == ':') {
- ++p;
+ p++;
}
len = modifier_len(p);
if (len == 0) {