changeset 29038:ad99b7b9df13 v8.2.5041

patch 8.2.5041: cannot close a terminal popup with "NONE" job Commit: https://github.com/vim/vim/commit/9e636b9d2ef54552383daebf290d916b3d001823 Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 29 22:37:05 2022 +0100 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)
author Bram Moolenaar <Bram@vim.org>
date Sun, 29 May 2022 23:45:03 +0200
parents 28cdce891562
children bffa38742374
files src/buffer.c src/proto/terminal.pro src/terminal.c src/testdir/test_popupwin.vim src/undo.c src/version.c
diffstat 6 files changed, 36 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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';
--- 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);
--- 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;
 
--- 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
--- 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);
--- 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,