1
0
forked from aniani/vim

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.
This commit is contained in:
Bram Moolenaar
2020-02-01 23:04:24 +01:00
parent 284d1c24e2
commit 3c01c4a028
8 changed files with 26 additions and 21 deletions

View File

@@ -638,7 +638,7 @@ do_argfile(exarg_T *eap, int argn)
char_u *p; char_u *p;
int old_arg_idx = curwin->w_arg_idx; int old_arg_idx = curwin->w_arg_idx;
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
if (argn < 0 || argn >= ARGCOUNT) if (argn < 0 || argn >= ARGCOUNT)
{ {

View File

@@ -4633,7 +4633,7 @@ ex_doautocmd(exarg_T *eap)
static void static void
ex_bunload(exarg_T *eap) ex_bunload(exarg_T *eap)
{ {
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
eap->errmsg = do_bufdel( eap->errmsg = do_bufdel(
eap->cmdidx == CMD_bdelete ? DOBUF_DEL eap->cmdidx == CMD_bdelete ? DOBUF_DEL
@@ -4649,7 +4649,7 @@ ex_bunload(exarg_T *eap)
static void static void
ex_buffer(exarg_T *eap) ex_buffer(exarg_T *eap)
{ {
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
if (*eap->arg) if (*eap->arg)
eap->errmsg = e_trailing; eap->errmsg = e_trailing;
@@ -4683,7 +4683,7 @@ ex_bmodified(exarg_T *eap)
static void static void
ex_bnext(exarg_T *eap) ex_bnext(exarg_T *eap)
{ {
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2);
@@ -4700,7 +4700,7 @@ ex_bnext(exarg_T *eap)
static void static void
ex_bprevious(exarg_T *eap) ex_bprevious(exarg_T *eap)
{ {
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2);
@@ -4717,7 +4717,7 @@ ex_bprevious(exarg_T *eap)
static void static void
ex_brewind(exarg_T *eap) ex_brewind(exarg_T *eap)
{ {
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); goto_buffer(eap, DOBUF_FIRST, FORWARD, 0);
@@ -4732,7 +4732,7 @@ ex_brewind(exarg_T *eap)
static void static void
ex_blast(exarg_T *eap) ex_blast(exarg_T *eap)
{ {
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); goto_buffer(eap, DOBUF_LAST, BACKWARD, 0);
@@ -5762,7 +5762,7 @@ ex_splitview(exarg_T *eap)
|| eap->cmdidx == CMD_tabfind || eap->cmdidx == CMD_tabfind
|| eap->cmdidx == CMD_tabnew; || eap->cmdidx == CMD_tabnew;
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
#ifdef FEAT_GUI #ifdef FEAT_GUI
@@ -6145,7 +6145,8 @@ do_exedit(
int need_hide; int need_hide;
int exmode_was = exmode_active; 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; return;
/* /*
* ":vi" command ends Ex mode. * ":vi" command ends Ex mode.

View File

@@ -344,9 +344,11 @@
// Give an error in curwin is a popup window and evaluate to TRUE. // Give an error in curwin is a popup window and evaluate to TRUE.
#ifdef FEAT_PROP_POPUP #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 #else
# define ERROR_IF_POPUP_WINDOW 0 # define ERROR_IF_POPUP_WINDOW 0
# define ERROR_IF_ANY_POPUP_WINDOW 0
#endif #endif
#if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL) #if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL)
# define ERROR_IF_TERM_POPUP_WINDOW error_if_term_popup_window() # define ERROR_IF_TERM_POPUP_WINDOW error_if_term_popup_window()

View File

@@ -2360,7 +2360,7 @@ f_popup_close(typval_T *argvars, typval_T *rettv UNUSED)
int id = (int)tv_get_number(argvars); int id = (int)tv_get_number(argvars);
win_T *wp; win_T *wp;
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
wp = find_popup_win(id); wp = find_popup_win(id);
@@ -2511,7 +2511,7 @@ popup_close_tabpage(tabpage_T *tp, int id)
void void
close_all_popups(void) close_all_popups(void)
{ {
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
while (first_popupwin != NULL) while (first_popupwin != NULL)
popup_close(first_popupwin->w_id); popup_close(first_popupwin->w_id);
@@ -2845,14 +2845,14 @@ f_popup_getoptions(typval_T *argvars, typval_T *rettv)
} }
int 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 // win_execute() may set "curwin" to a popup window temporarily, but many
// commands are disallowed then. When a terminal runs in the popup most // commands are disallowed then. When a terminal runs in the popup most
// things are allowed. // things are allowed.
if (WIN_IS_POPUP(curwin) if (WIN_IS_POPUP(curwin)
# ifdef FEAT_TERMINAL # ifdef FEAT_TERMINAL
&& curbuf->b_term == NULL && (also_with_term || curbuf->b_term == NULL)
# endif # endif
) )
{ {

View File

@@ -41,7 +41,7 @@ void f_popup_setoptions(typval_T *argvars, typval_T *rettv);
void f_popup_getpos(typval_T *argvars, typval_T *rettv); void f_popup_getpos(typval_T *argvars, typval_T *rettv);
void f_popup_locate(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); 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); int error_if_term_popup_window(void);
void popup_reset_handled(int handled_flag); void popup_reset_handled(int handled_flag);
win_T *find_next_popup(int lowest, int handled_flag); win_T *find_next_popup(int lowest, int handled_flag);

View File

@@ -2357,7 +2357,7 @@ func Test_terminal_in_popup()
call VerifyScreenDump(buf, 'Test_terminal_popup_3', {}) call VerifyScreenDump(buf, 'Test_terminal_popup_3', {})
call term_sendkeys(buf, ":q\<CR>") call term_sendkeys(buf, ":q\<CR>")
call term_wait(buf, 50) " wait for terminal to vanish call term_wait(buf, 100) " wait for terminal to vanish
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XtermPopup') call delete('XtermPopup')

View File

@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
194,
/**/ /**/
193, 193,
/**/ /**/

View File

@@ -122,7 +122,7 @@ do_window(
#endif #endif
char_u cbuf[40]; char_u cbuf[40];
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
#ifdef FEAT_CMDWIN #ifdef FEAT_CMDWIN
@@ -784,7 +784,7 @@ check_split_disallowed()
int int
win_split(int size, int flags) win_split(int size, int flags)
{ {
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return FAIL; return FAIL;
// When the ":tab" modifier was used open a new tab page instead. // When the ":tab" modifier was used open a new tab page instead.
@@ -1574,7 +1574,7 @@ win_exchange(long Prenum)
win_T *wp2; win_T *wp2;
int temp; int temp;
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
if (ONE_WINDOW) // just one window 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; int had_diffmode = win->w_p_diff;
#endif #endif
if (ERROR_IF_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return FAIL; return FAIL;
if (last_window()) if (last_window())
@@ -4344,7 +4344,7 @@ win_goto(win_T *wp)
#endif #endif
#ifdef FEAT_PROP_POPUP #ifdef FEAT_PROP_POPUP
if (ERROR_IF_POPUP_WINDOW || ERROR_IF_TERM_POPUP_WINDOW) if (ERROR_IF_ANY_POPUP_WINDOW)
return; return;
if (popup_is_popup(wp)) if (popup_is_popup(wp))
{ {