aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/funcs.c
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2023-06-23 22:32:07 +0100
committerSean Dewar <seandewar@users.noreply.github.com>2023-07-05 08:33:32 +0100
commitaa4e47f704c53ab1d825260d2bf34e2872e3ca89 (patch)
tree872bb909c1001e59a16783e973a0e0bb831417e8 /src/nvim/eval/funcs.c
parent77118d0da8badc4135be430f4cbb15bc95bc760f (diff)
downloadrneovim-aa4e47f704c53ab1d825260d2bf34e2872e3ca89.tar.gz
rneovim-aa4e47f704c53ab1d825260d2bf34e2872e3ca89.tar.bz2
rneovim-aa4e47f704c53ab1d825260d2bf34e2872e3ca89.zip
fix(api): disallow some more functions during textlock
Problem: nvim_buf_set_text(), nvim_open_term() and termopen() all change buffer text, which is forbidden during textlock. Additionally, nvim_open_term() and termopen() may be used to convert the cmdwin buffer into a terminal buffer, which is weird. Solution: Allow nvim_buf_set_text() and nvim_open_term() in the cmdwin, but disallow nvim_open_term() from converting the cmdwin buffer into a terminal buffer. termopen() is not allowed in the cmdwin (as it always operates on curbuf), so just check text_locked(). Also happens to improve the error in #21055: nvim_buf_set_text() was callable during textlock, but happened to check textlock indirectly via u_save(); however, this caused the error to be overwritten by an unhelpful "Failed to save undo information" message when msg_list == NULL (e.g: an `<expr>` mapping invoked outside of do_cmdline()).
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r--src/nvim/eval/funcs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index f348a61075..7c3c5cc274 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -8385,7 +8385,10 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (check_secure()) {
return;
}
-
+ if (text_locked()) {
+ text_locked_msg();
+ return;
+ }
if (curbuf->b_changed) {
emsg(_("Can only call this function in an unmodified buffer"));
return;