summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-29 22:37:05 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-29 22:37:05 +0100
commit9e636b9d2ef54552383daebf290d916b3d001823 (patch)
treede1946ef20a5338f42dbf38b36c8e748b989001a
parentfc376e0b1a36a2ef153e28752c61342554386886 (diff)
patch 8.2.5041: cannot close a terminal popup with "NONE" jobv8.2.5041
Problem: Cannot close a terminal popup with "NONE" job. Solution: Adjust the conditions for whether a job is running. (closes #10498)
-rw-r--r--src/buffer.c6
-rw-r--r--src/proto/terminal.pro1
-rw-r--r--src/terminal.c12
-rw-r--r--src/testdir/test_popupwin.vim18
-rw-r--r--src/undo.c2
-rw-r--r--src/version.c2
6 files changed, 36 insertions, 5 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 88528e9f33..efec431c82 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -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';
diff --git a/src/proto/terminal.pro b/src/proto/terminal.pro
index 0736563111..9de563115d 100644
--- a/src/proto/terminal.pro
+++ b/src/proto/terminal.pro
@@ -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);
diff --git a/src/terminal.c b/src/terminal.c
index 6df37220be..fddd087c9b 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1630,6 +1630,16 @@ term_job_running(term_T *term)
}
/*
+ * 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".
*/
int
@@ -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;
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index d3a57b04b0..7fc5ef5730 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -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
diff --git a/src/undo.c b/src/undo.c
index 7ebad1cef9..924108cedc 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -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);
diff --git a/src/version.c b/src/version.c
index 0d8e1756f0..cbe6ff4d68 100644
--- a/src/version.c
+++ b/src/version.c
@@ -735,6 +735,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 5041,
+/**/
5040,
/**/
5039,