@@ -2492,6 +2492,31 @@ popup_free(win_T *wp)
24922492 popup_mask_refresh = TRUE;
24932493}
24942494
2495+ static void
2496+ error_for_popup_window (void )
2497+ {
2498+ emsg (_ ("E994: Not allowed in a popup window" ));
2499+ }
2500+
2501+ int
2502+ error_if_popup_window (int also_with_term UNUSED )
2503+ {
2504+ // win_execute() may set "curwin" to a popup window temporarily, but many
2505+ // commands are disallowed then. When a terminal runs in the popup most
2506+ // things are allowed. When a terminal is finished it can be closed.
2507+ if (WIN_IS_POPUP (curwin )
2508+ # ifdef FEAT_TERMINAL
2509+ && (also_with_term || curbuf -> b_term == NULL )
2510+ && !term_is_finished (curbuf )
2511+ # endif
2512+ )
2513+ {
2514+ error_for_popup_window ();
2515+ return TRUE;
2516+ }
2517+ return FALSE;
2518+ }
2519+
24952520/*
24962521 * Close a popup window by Window-id.
24972522 * Does not invoke the callback.
@@ -2509,7 +2534,7 @@ popup_close(int id)
25092534 {
25102535 if (wp == curwin )
25112536 {
2512- ERROR_IF_ANY_POPUP_WINDOW ;
2537+ error_for_popup_window () ;
25132538 return ;
25142539 }
25152540 if (prev == NULL )
@@ -2540,7 +2565,7 @@ popup_close_tabpage(tabpage_T *tp, int id)
25402565 {
25412566 if (wp == curwin )
25422567 {
2543- ERROR_IF_ANY_POPUP_WINDOW ;
2568+ error_for_popup_window () ;
25442569 return ;
25452570 }
25462571 if (prev == NULL )
@@ -2888,25 +2913,6 @@ f_popup_getoptions(typval_T *argvars, typval_T *rettv)
28882913 }
28892914}
28902915
2891- int
2892- error_if_popup_window (int also_with_term UNUSED )
2893- {
2894- // win_execute() may set "curwin" to a popup window temporarily, but many
2895- // commands are disallowed then. When a terminal runs in the popup most
2896- // things are allowed. When a terminal is finished it can be closed.
2897- if (WIN_IS_POPUP (curwin )
2898- # ifdef FEAT_TERMINAL
2899- && (also_with_term || curbuf -> b_term == NULL )
2900- && !term_is_finished (curbuf )
2901- # endif
2902- )
2903- {
2904- emsg (_ ("E994: Not allowed in a popup window" ));
2905- return TRUE;
2906- }
2907- return FALSE;
2908- }
2909-
29102916# if defined(FEAT_TERMINAL ) || defined(PROTO )
29112917/*
29122918 * Return TRUE if the current window is running a terminal in a popup window.
0 commit comments