aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/eval')
-rw-r--r--src/nvim/eval/buffer.c15
-rw-r--r--src/nvim/eval/vars.c12
-rw-r--r--src/nvim/eval/window.c4
3 files changed, 16 insertions, 15 deletions
diff --git a/src/nvim/eval/buffer.c b/src/nvim/eval/buffer.c
index 4816a955a8..6ebf54ef0f 100644
--- a/src/nvim/eval/buffer.c
+++ b/src/nvim/eval/buffer.c
@@ -86,6 +86,8 @@ 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);
@@ -103,7 +105,9 @@ 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);
- cob->cob_using_aco = true;
+ if (curbuf == buf) {
+ cob->cob_using_aco = true;
+ }
}
}
@@ -302,13 +306,8 @@ void f_bufload(typval_T *argvars, typval_T *unused, EvalFuncData fptr)
{
buf_T *buf = get_buf_arg(&argvars[0]);
- if (buf != NULL && buf->b_ml.ml_mfp == NULL) {
- aco_save_T aco;
-
- aucmd_prepbuf(&aco, buf);
- swap_exists_action = SEA_NONE;
- open_buffer(false, NULL, 0);
- aucmd_restbuf(&aco);
+ if (buf != NULL) {
+ buffer_ensure_loaded(buf);
}
}
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
index 5459eac5bf..f002071ad2 100644
--- a/src/nvim/eval/vars.c
+++ b/src/nvim/eval/vars.c
@@ -1800,13 +1800,15 @@ void f_setbufvar(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (*varname == '&') {
aco_save_T aco;
- // set curbuf to be our buf, temporarily
+ // 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);
- set_option_from_tv(varname + 1, varp);
-
- // reset notion of buffer
- aucmd_restbuf(&aco);
+ // reset notion of buffer
+ aucmd_restbuf(&aco);
+ }
} else {
const size_t varname_len = strlen(varname);
char *const bufvarname = xmalloc(varname_len + 3);
diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c
index d6c761bc66..7cb346216d 100644
--- a/src/nvim/eval/window.c
+++ b/src/nvim/eval/window.c
@@ -590,7 +590,7 @@ static void win_move_into_split(win_T *wp, win_T *targetwin, int size, int flags
int height = wp->w_height;
win_T *oldwin = curwin;
- if (wp == targetwin || wp == aucmd_win) {
+ if (wp == targetwin || is_aucmd_win(wp)) {
return;
}
@@ -674,7 +674,7 @@ void f_win_gettype(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
return;
}
}
- if (wp == aucmd_win) {
+ if (is_aucmd_win(wp)) {
rettv->vval.v_string = xstrdup("autocmd");
} else if (wp->w_p_pvw) {
rettv->vval.v_string = xstrdup("preview");