# HG changeset patch # User Bram Moolenaar # Date 1559230206 -7200 # Node ID f8e28c6ae8ab85e040fcfb9b1f0ac10b828100e8 # Parent 339949bc111a49f7b0354060b0a07fecb536be89 patch 8.1.1425: win_execute() does not set window pointers properly commit https://github.com/vim/vim/commit/89adc3a1371d211f7766f3dbc0975ecb2f862327 Author: Bram Moolenaar Date: Thu May 30 17:29:40 2019 +0200 patch 8.1.1425: win_execute() does not set window pointers properly Problem: Win_execute() does not set window pointers properly. Solution: Use switch_win_noblock(). Also execute autocommands in a popup window. diff --git a/src/autocmd.c b/src/autocmd.c --- a/src/autocmd.c +++ b/src/autocmd.c @@ -1349,7 +1349,7 @@ ex_doautoall(exarg_T *eap) */ FOR_ALL_BUFFERS(buf) { - if (buf->b_ml.ml_mfp != NULL && !bt_popup(buf)) + if (buf->b_ml.ml_mfp != NULL) { // find a window for this buffer and save some values aucmd_prepbuf(&aco, buf); @@ -1612,8 +1612,6 @@ apply_autocmds( int force, // when TRUE, ignore autocmd_busy buf_T *buf) // buffer for { - if (bt_popup(buf)) - return FALSE; return apply_autocmds_group(event, fname, fname_io, force, AUGROUP_ALL, buf, NULL); } diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -6116,19 +6116,18 @@ f_win_execute(typval_T *argvars, typval_ { int id = (int)tv_get_number(argvars); win_T *wp = win_id2wp(id); - win_T *save_curwin = curwin; + win_T *save_curwin; + tabpage_T *save_curtab; if (wp != NULL) { - curwin = wp; - curbuf = curwin->w_buffer; - check_cursor(); - execute_common(argvars, rettv, 1); - if (win_valid(save_curwin)) - { - curwin = save_curwin; - curbuf = curwin->w_buffer; - } + if (switch_win_noblock(&save_curwin, &save_curtab, wp, curtab, TRUE) + == OK) + { + check_cursor(); + execute_common(argvars, rettv, 1); + } + restore_win_noblock(save_curwin, save_curtab, TRUE); } } diff --git a/src/proto/window.pro b/src/proto/window.pro --- a/src/proto/window.pro +++ b/src/proto/window.pro @@ -77,7 +77,9 @@ void reset_lnums(void); void make_snapshot(int idx); void restore_snapshot(int idx, int close_curwin); int switch_win(win_T **save_curwin, tabpage_T **save_curtab, win_T *win, tabpage_T *tp, int no_display); +int switch_win_noblock(win_T **save_curwin, tabpage_T **save_curtab, win_T *win, tabpage_T *tp, int no_display); void restore_win(win_T *save_curwin, tabpage_T *save_curtab, int no_display); +void restore_win_noblock(win_T *save_curwin, tabpage_T *save_curtab, int no_display); void switch_buffer(bufref_T *save_curbuf, buf_T *buf); void restore_buffer(bufref_T *save_curbuf); int win_hasvertsplit(void); diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -768,6 +768,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1425, +/**/ 1424, /**/ 1423, diff --git a/src/window.c b/src/window.c --- a/src/window.c +++ b/src/window.c @@ -6495,6 +6495,20 @@ switch_win( int no_display) { block_autocmds(); + return switch_win_noblock(save_curwin, save_curtab, win, tp, no_display); +} + +/* + * As switch_win() but without blocking autocommands. + */ + int +switch_win_noblock( + win_T **save_curwin, + tabpage_T **save_curtab, + win_T *win, + tabpage_T *tp, + int no_display) +{ *save_curwin = curwin; if (tp != NULL) { @@ -6524,9 +6538,22 @@ switch_win( */ void restore_win( - win_T *save_curwin UNUSED, - tabpage_T *save_curtab UNUSED, - int no_display UNUSED) + win_T *save_curwin, + tabpage_T *save_curtab, + int no_display) +{ + restore_win_noblock(save_curwin, save_curtab, no_display); + unblock_autocmds(); +} + +/* + * As restore_win() but without unblocking autocommands. + */ + void +restore_win_noblock( + win_T *save_curwin, + tabpage_T *save_curtab, + int no_display) { if (save_curtab != NULL && valid_tabpage(save_curtab)) { @@ -6546,7 +6573,6 @@ restore_win( curwin = save_curwin; curbuf = curwin->w_buffer; } - unblock_autocmds(); } /*