mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.0196: blocking commands for a finished job in a popup window
Problem: Blocking commands for a finished job in a popup window. Solution: Do not block commands if the job has finished. Adjust test.
This commit is contained in:
parent
3180fe6c6d
commit
d98c0b63ab
@ -2863,10 +2863,15 @@ error_if_popup_window(int also_with_term UNUSED)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# if defined(FEAT_TERMINAL) || defined(PROTO)
|
# if defined(FEAT_TERMINAL) || defined(PROTO)
|
||||||
|
/*
|
||||||
|
* Return TRUE if the current window is running a terminal in a popup window.
|
||||||
|
* Return FALSE when the job has ended.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
error_if_term_popup_window()
|
error_if_term_popup_window()
|
||||||
{
|
{
|
||||||
if (WIN_IS_POPUP(curwin) && curbuf->b_term != NULL)
|
if (WIN_IS_POPUP(curwin) && curbuf->b_term != NULL
|
||||||
|
&& term_job_running(curbuf->b_term))
|
||||||
{
|
{
|
||||||
emsg(_("E899: Not allowed for a terminal in a popup window"));
|
emsg(_("E899: Not allowed for a terminal in a popup window"));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -19,6 +19,7 @@ cursorentry_T *term_get_cursor_shape(guicolor_T *fg, guicolor_T *bg);
|
|||||||
int term_use_loop(void);
|
int term_use_loop(void);
|
||||||
void term_win_entered(void);
|
void term_win_entered(void);
|
||||||
int terminal_loop(int blocking);
|
int terminal_loop(int blocking);
|
||||||
|
int may_close_term_popup(void);
|
||||||
void term_channel_closed(channel_T *ch);
|
void term_channel_closed(channel_T *ch);
|
||||||
void term_check_channel_closed_recently(void);
|
void term_check_channel_closed_recently(void);
|
||||||
int term_do_update_window(win_T *wp);
|
int term_do_update_window(win_T *wp);
|
||||||
|
@ -3260,6 +3260,29 @@ term_after_channel_closed(term_T *term)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(FEAT_PROP_POPUP) || defined(PROTO)
|
||||||
|
/*
|
||||||
|
* If the current window is a terminal in a popup window and the job has
|
||||||
|
* finished, close the popup window and to back to the previous window.
|
||||||
|
* Otherwise return FAIL.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
may_close_term_popup(void)
|
||||||
|
{
|
||||||
|
if (popup_is_popup(curwin) && curbuf->b_term != NULL
|
||||||
|
&& !term_job_running(curbuf->b_term))
|
||||||
|
{
|
||||||
|
win_T *pwin = curwin;
|
||||||
|
|
||||||
|
if (win_valid(prevwin))
|
||||||
|
win_enter(prevwin, FALSE);
|
||||||
|
popup_close_with_retval(pwin, 0);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called when a channel has been closed.
|
* Called when a channel has been closed.
|
||||||
* If this was a channel for a terminal window then finish it up.
|
* If this was a channel for a terminal window then finish it up.
|
||||||
|
@ -2396,10 +2396,20 @@ endfunc
|
|||||||
|
|
||||||
func Test_popupwin_terminal_buffer()
|
func Test_popupwin_terminal_buffer()
|
||||||
CheckFeature terminal
|
CheckFeature terminal
|
||||||
|
CheckUnix
|
||||||
|
|
||||||
|
let origwin = win_getid()
|
||||||
let ptybuf = term_start(&shell, #{hidden: 1})
|
let ptybuf = term_start(&shell, #{hidden: 1})
|
||||||
call assert_fails('let winnr = popup_create(ptybuf, #{})', 'E278:')
|
let winnr = popup_create(ptybuf, #{minwidth: 40, minheight: 10})
|
||||||
exe 'bwipe! ' .. ptybuf
|
" Wait for shell to start
|
||||||
|
sleep 200m
|
||||||
|
" Cannot quit while job is running
|
||||||
|
call assert_fails('call feedkeys("\<C-W>:quit\<CR>", "xt")', 'E948:')
|
||||||
|
call feedkeys("exit\<CR>", 'xt')
|
||||||
|
" Wait for shell to exit
|
||||||
|
sleep 100m
|
||||||
|
call feedkeys(":quit\<CR>", 'xt')
|
||||||
|
call assert_equal(origwin, win_getid())
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_popupwin_with_buffer_and_filter()
|
func Test_popupwin_with_buffer_and_filter()
|
||||||
|
@ -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 */
|
||||||
|
/**/
|
||||||
|
196,
|
||||||
/**/
|
/**/
|
||||||
195,
|
195,
|
||||||
/**/
|
/**/
|
||||||
|
11
src/window.c
11
src/window.c
@ -2441,6 +2441,11 @@ 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 defined(FEAT_TERMINAL) && defined(FEAT_PROP_POPUP)
|
||||||
|
// Can close a popup window with a terminal if the job has finished.
|
||||||
|
if (may_close_term_popup() == OK)
|
||||||
|
return OK;
|
||||||
|
#endif
|
||||||
if (ERROR_IF_ANY_POPUP_WINDOW)
|
if (ERROR_IF_ANY_POPUP_WINDOW)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
@ -6439,6 +6444,12 @@ only_one_window(void)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
win_T *wp;
|
win_T *wp;
|
||||||
|
|
||||||
|
#if defined(FEAT_PROP_POPUP)
|
||||||
|
// If the current window is a popup then there always is another window.
|
||||||
|
if (popup_is_popup(curwin))
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
// If there is another tab page there always is another window.
|
// If there is another tab page there always is another window.
|
||||||
if (first_tabpage->tp_next != NULL)
|
if (first_tabpage->tp_next != NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user