]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.5041: cannot close a terminal popup with "NONE" job v8.2.5041
authorBram Moolenaar <Bram@vim.org>
Sun, 29 May 2022 21:37:05 +0000 (22:37 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 29 May 2022 21:37:05 +0000 (22:37 +0100)
Problem:    Cannot close a terminal popup with "NONE" job.
Solution:   Adjust the conditions for whether a job is running.
            (closes #10498)

src/buffer.c
src/proto/terminal.pro
src/terminal.c
src/testdir/test_popupwin.vim
src/undo.c
src/version.c

index 88528e9f33a6cb656dae71fd9a6741394bf7693a..efec431c822dfe49b2475df4827332c1b096a325 100644 (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';
index 07365631115b2449cd652f7868bbadbbcb115019..9de563115d7ec03fe51d035e6e0e11cf88c5db3d 100644 (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);
index 6df37220be8b332a2cbd02658389a812d7a0fe64..fddd087c9b279969cec22f3b87cb875cbdcf8f94 100644 (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;
 
index d3a57b04b0151d48a30e62178777d3cb8df13f03..7fc5ef57309053d34e762678ae17461b93c6747f 100644 (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
index 7ebad1cef9242dd4823902b78d5cc4df4778b24f..924108cedc9077c3deabac161f101d40d825d2e1 100644 (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);
index 0d8e1756f0f1b118e0063f00742d1a256321a2dc..cbe6ff4d683c2fc24768ac9261436ee315c87e2f 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5041,
 /**/
     5040,
 /**/