0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.5041: cannot close a terminal popup with "NONE" job

Problem:    Cannot close a terminal popup with "NONE" job.
Solution:   Adjust the conditions for whether a job is running.
            (closes #10498)
This commit is contained in:
Bram Moolenaar
2022-05-29 22:37:05 +01:00
parent fc376e0b1a
commit 9e636b9d2e
6 changed files with 36 additions and 5 deletions

View File

@@ -3282,7 +3282,7 @@ buflist_list(exarg_T *eap)
{
#ifdef FEAT_TERMINAL
job_running = term_job_running(buf->b_term);
job_none_open = job_running && term_none_open(buf->b_term);
job_none_open = term_none_open(buf->b_term);
#endif
// skip unlisted buffers, unless ! was used
if ((!buf->b_p_bl && !eap->forceit && !vim_strchr(eap->arg, 'u'))
@@ -3318,9 +3318,9 @@ buflist_list(exarg_T *eap)
changed_char = (buf->b_flags & BF_READERR) ? 'x'
: (bufIsChanged(buf) ? '+' : ' ');
#ifdef FEAT_TERMINAL
if (term_job_running(buf->b_term))
if (job_running)
{
if (term_none_open(buf->b_term))
if (job_none_open)
ro_char = '?';
else
ro_char = 'R';

View File

@@ -8,6 +8,7 @@ void free_terminal(buf_T *buf);
void free_unused_terminals(void);
void write_to_term(buf_T *buffer, char_u *msg, channel_T *channel);
int term_job_running(term_T *term);
int term_job_running_not_none(term_T *term);
int term_none_open(term_T *term);
int term_try_stop_job(buf_T *buf);
int term_check_timers(int next_due_arg, proftime_T *now);

View File

@@ -1629,6 +1629,16 @@ term_job_running(term_T *term)
return term_job_running_check(term, FALSE);
}
/*
* Return TRUE if the job for "term" is still running, ignoring the job was
* "NONE".
*/
int
term_job_running_not_none(term_T *term)
{
return term_job_running(term) && !term_none_open(term);
}
/*
* Return TRUE if "term" has an active channel and used ":term NONE".
*/
@@ -3512,7 +3522,7 @@ term_after_channel_closed(term_T *term)
may_close_term_popup(void)
{
if (popup_is_popup(curwin) && curbuf->b_term != NULL
&& !term_job_running(curbuf->b_term))
&& !term_job_running_not_none(curbuf->b_term))
{
win_T *pwin = curwin;

View File

@@ -2880,6 +2880,24 @@ func Test_popupwin_terminal_buffer()
call assert_equal(origwin, win_getid())
endfunc
func Test_popupwin_terminal_buffer_none()
CheckFeature terminal
CheckUnix
" Starting a terminal to run a shell in is considered flaky.
let g:test_is_flaky = 1
let origwin = win_getid()
call term_start("NONE", {"hidden": 1})->popup_create({"border": []})
sleep 50m
" since no actual job is running can close the window with :quit
call feedkeys("\<C-W>:q\<CR>", 'xt')
call assert_equal([], popup_list())
call assert_equal(origwin, win_getid())
endfunc
func Test_popupwin_terminal_scrollbar()
CheckFeature terminal
CheckScreendump

View File

@@ -3574,7 +3574,7 @@ u_blockfree(buf_T *buf)
bufIsChanged(buf_T *buf)
{
#ifdef FEAT_TERMINAL
if (term_job_running(buf->b_term))
if (term_job_running_not_none(buf->b_term))
return TRUE;
#endif
return bufIsChangedNotTerm(buf);

View File

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