aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-02 20:39:24 +0800
committerGitHub <noreply@github.com>2022-12-02 20:39:24 +0800
commit1145a9b2485a4e5072cffe28a958da983cd59e84 (patch)
tree13059f09a9825a7eae3d75c8556436845dc1e492 /src/nvim/eval
parent805c83f43e3d6832a54bc4a1de1dd4d4da43d58e (diff)
downloadrneovim-1145a9b2485a4e5072cffe28a958da983cd59e84.tar.gz
rneovim-1145a9b2485a4e5072cffe28a958da983cd59e84.tar.bz2
rneovim-1145a9b2485a4e5072cffe28a958da983cd59e84.zip
feat(aucmd_win): allow crazy things with hidden buffers (#21250)
Problem: Crash when doing crazy things with hidden buffers. Solution: Dynamically allocate the list of autocommand windows.
Diffstat (limited to 'src/nvim/eval')
-rw-r--r--src/nvim/eval/buffer.c6
-rw-r--r--src/nvim/eval/vars.c10
2 files changed, 5 insertions, 11 deletions
diff --git a/src/nvim/eval/buffer.c b/src/nvim/eval/buffer.c
index 6ebf54ef0f..72eb0f8d67 100644
--- a/src/nvim/eval/buffer.c
+++ b/src/nvim/eval/buffer.c
@@ -86,8 +86,6 @@ static void find_win_for_curbuf(void)
///
/// Information is saved in "cob" and MUST be restored by calling
/// change_other_buffer_restore().
-///
-/// If this fails then "curbuf" will not be equal to "buf".
static void change_other_buffer_prepare(cob_T *cob, buf_T *buf)
{
CLEAR_POINTER(cob);
@@ -105,9 +103,7 @@ static void change_other_buffer_prepare(cob_T *cob, buf_T *buf)
// curwin->w_buffer differ from "curbuf", use the autocmd window.
curbuf = curwin->w_buffer;
aucmd_prepbuf(&cob->cob_aco, buf);
- if (curbuf == buf) {
- cob->cob_using_aco = true;
- }
+ cob->cob_using_aco = true;
}
}
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
index f002071ad2..d37631af8c 100644
--- a/src/nvim/eval/vars.c
+++ b/src/nvim/eval/vars.c
@@ -1802,13 +1802,11 @@ void f_setbufvar(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
// Set curbuf to be our buf, temporarily.
aucmd_prepbuf(&aco, buf);
- if (curbuf == buf) {
- // Only when it worked to set "curbuf".
- set_option_from_tv(varname + 1, varp);
- // reset notion of buffer
- aucmd_restbuf(&aco);
- }
+ set_option_from_tv(varname + 1, varp);
+
+ // reset notion of buffer
+ aucmd_restbuf(&aco);
} else {
const size_t varname_len = strlen(varname);
char *const bufvarname = xmalloc(varname_len + 3);