Problem: Cannot close a terminal popup with "NONE" job.
Solution: Adjust the conditions for whether a job is running.
(closes #10498)
{
#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'))
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';
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);
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".
*/
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;
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
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);
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 5041,
/**/
5040,
/**/