# HG changeset patch # User Bram Moolenaar # Date 1580595303 -3600 # Node ID ebeeb4b4a1faf0f6a2c1479e752c2fdfa2697cd7 # Parent 6eca0794f137f4b95707b1500c310d5847d6f709 patch 8.2.0194: some commands can cause problems in terminal popup Commit: https://github.com/vim/vim/commit/3c01c4a02897163996639f6f2604c68eab2bd18b Author: Bram Moolenaar Date: Sat Feb 1 23:04:24 2020 +0100 patch 8.2.0194: some commands can cause problems in terminal popup Problem: Some commands can cause problems in terminal popup. Solution: Disallow more commands. diff --git a/src/arglist.c b/src/arglist.c --- a/src/arglist.c +++ b/src/arglist.c @@ -638,7 +638,7 @@ do_argfile(exarg_T *eap, int argn) char_u *p; int old_arg_idx = curwin->w_arg_idx; - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; if (argn < 0 || argn >= ARGCOUNT) { diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -4633,7 +4633,7 @@ ex_doautocmd(exarg_T *eap) static void ex_bunload(exarg_T *eap) { - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; eap->errmsg = do_bufdel( eap->cmdidx == CMD_bdelete ? DOBUF_DEL @@ -4649,7 +4649,7 @@ ex_bunload(exarg_T *eap) static void ex_buffer(exarg_T *eap) { - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; if (*eap->arg) eap->errmsg = e_trailing; @@ -4683,7 +4683,7 @@ ex_bmodified(exarg_T *eap) static void ex_bnext(exarg_T *eap) { - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); @@ -4700,7 +4700,7 @@ ex_bnext(exarg_T *eap) static void ex_bprevious(exarg_T *eap) { - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); @@ -4717,7 +4717,7 @@ ex_bprevious(exarg_T *eap) static void ex_brewind(exarg_T *eap) { - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); @@ -4732,7 +4732,7 @@ ex_brewind(exarg_T *eap) static void ex_blast(exarg_T *eap) { - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); @@ -5762,7 +5762,7 @@ ex_splitview(exarg_T *eap) || eap->cmdidx == CMD_tabfind || eap->cmdidx == CMD_tabnew; - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; #ifdef FEAT_GUI @@ -6145,7 +6145,8 @@ do_exedit( int need_hide; int exmode_was = exmode_active; - if (eap->cmdidx != CMD_pedit && ERROR_IF_POPUP_WINDOW) + if ((eap->cmdidx != CMD_pedit && ERROR_IF_POPUP_WINDOW) + || ERROR_IF_TERM_POPUP_WINDOW) return; /* * ":vi" command ends Ex mode. diff --git a/src/macros.h b/src/macros.h --- a/src/macros.h +++ b/src/macros.h @@ -344,9 +344,11 @@ // Give an error in curwin is a popup window and evaluate to TRUE. #ifdef FEAT_PROP_POPUP -# define ERROR_IF_POPUP_WINDOW error_if_popup_window() +# define ERROR_IF_POPUP_WINDOW error_if_popup_window(FALSE) +# define ERROR_IF_ANY_POPUP_WINDOW error_if_popup_window(TRUE) #else # define ERROR_IF_POPUP_WINDOW 0 +# define ERROR_IF_ANY_POPUP_WINDOW 0 #endif #if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL) # define ERROR_IF_TERM_POPUP_WINDOW error_if_term_popup_window() diff --git a/src/popupwin.c b/src/popupwin.c --- a/src/popupwin.c +++ b/src/popupwin.c @@ -2360,7 +2360,7 @@ f_popup_close(typval_T *argvars, typval_ int id = (int)tv_get_number(argvars); win_T *wp; - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; wp = find_popup_win(id); @@ -2511,7 +2511,7 @@ popup_close_tabpage(tabpage_T *tp, int i void close_all_popups(void) { - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; while (first_popupwin != NULL) popup_close(first_popupwin->w_id); @@ -2845,14 +2845,14 @@ f_popup_getoptions(typval_T *argvars, ty } int -error_if_popup_window() +error_if_popup_window(int also_with_term UNUSED) { // win_execute() may set "curwin" to a popup window temporarily, but many // commands are disallowed then. When a terminal runs in the popup most // things are allowed. if (WIN_IS_POPUP(curwin) # ifdef FEAT_TERMINAL - && curbuf->b_term == NULL + && (also_with_term || curbuf->b_term == NULL) # endif ) { diff --git a/src/proto/popupwin.pro b/src/proto/popupwin.pro --- a/src/proto/popupwin.pro +++ b/src/proto/popupwin.pro @@ -41,7 +41,7 @@ void f_popup_setoptions(typval_T *argvar void f_popup_getpos(typval_T *argvars, typval_T *rettv); void f_popup_locate(typval_T *argvars, typval_T *rettv); void f_popup_getoptions(typval_T *argvars, typval_T *rettv); -int error_if_popup_window(void); +int error_if_popup_window(int also_with_term); int error_if_term_popup_window(void); void popup_reset_handled(int handled_flag); win_T *find_next_popup(int lowest, int handled_flag); diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -2357,7 +2357,7 @@ func Test_terminal_in_popup() call VerifyScreenDump(buf, 'Test_terminal_popup_3', {}) call term_sendkeys(buf, ":q\") - call term_wait(buf, 50) " wait for terminal to vanish + call term_wait(buf, 100) " wait for terminal to vanish call StopVimInTerminal(buf) call delete('XtermPopup') diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 194, +/**/ 193, /**/ 192, diff --git a/src/window.c b/src/window.c --- a/src/window.c +++ b/src/window.c @@ -122,7 +122,7 @@ do_window( #endif char_u cbuf[40]; - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; #ifdef FEAT_CMDWIN @@ -784,7 +784,7 @@ check_split_disallowed() int win_split(int size, int flags) { - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return FAIL; // When the ":tab" modifier was used open a new tab page instead. @@ -1574,7 +1574,7 @@ win_exchange(long Prenum) win_T *wp2; int temp; - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; if (ONE_WINDOW) // just one window { @@ -2441,7 +2441,7 @@ win_close(win_T *win, int free_buf) int had_diffmode = win->w_p_diff; #endif - if (ERROR_IF_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return FAIL; if (last_window()) @@ -4344,7 +4344,7 @@ win_goto(win_T *wp) #endif #ifdef FEAT_PROP_POPUP - if (ERROR_IF_POPUP_WINDOW || ERROR_IF_TERM_POPUP_WINDOW) + if (ERROR_IF_ANY_POPUP_WINDOW) return; if (popup_is_popup(wp)) {