To: vim_dev@googlegroups.com Subject: Patch 8.2.5041 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.5041 Problem: Cannot close a terminal popup with "NONE" job. Solution: Adjust the conditions for whether a job is running. (closes #10498) Files: src/buffer.c, src/terminal.c, src/proto/terminal.pro, src/undo.c, src/testdir/test_popupwin.vim *** ../vim-8.2.5040/src/buffer.c 2022-05-21 20:16:51.003567195 +0100 --- src/buffer.c 2022-05-29 22:17:04.484723469 +0100 *************** *** 3282,3288 **** { #ifdef FEAT_TERMINAL job_running = term_job_running(buf->b_term); ! job_none_open = job_running && 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')) --- 3282,3288 ---- { #ifdef FEAT_TERMINAL job_running = term_job_running(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,3326 **** changed_char = (buf->b_flags & BF_READERR) ? 'x' : (bufIsChanged(buf) ? '+' : ' '); #ifdef FEAT_TERMINAL ! if (term_job_running(buf->b_term)) { ! if (term_none_open(buf->b_term)) ro_char = '?'; else ro_char = 'R'; --- 3318,3326 ---- changed_char = (buf->b_flags & BF_READERR) ? 'x' : (bufIsChanged(buf) ? '+' : ' '); #ifdef FEAT_TERMINAL ! if (job_running) { ! if (job_none_open) ro_char = '?'; else ro_char = 'R'; *** ../vim-8.2.5040/src/terminal.c 2022-05-26 14:06:33.061676874 +0100 --- src/terminal.c 2022-05-29 22:27:51.612212378 +0100 *************** *** 1630,1635 **** --- 1630,1645 ---- } /* + * 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,3518 **** may_close_term_popup(void) { if (popup_is_popup(curwin) && curbuf->b_term != NULL ! && !term_job_running(curbuf->b_term)) { win_T *pwin = curwin; --- 3522,3528 ---- may_close_term_popup(void) { if (popup_is_popup(curwin) && curbuf->b_term != NULL ! && !term_job_running_not_none(curbuf->b_term)) { win_T *pwin = curwin; *** ../vim-8.2.5040/src/proto/terminal.pro 2022-05-20 10:10:29.948122642 +0100 --- src/proto/terminal.pro 2022-05-29 22:21:04.304485486 +0100 *************** *** 8,13 **** --- 8,14 ---- 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); *** ../vim-8.2.5040/src/undo.c 2022-05-27 17:26:50.546119970 +0100 --- src/undo.c 2022-05-29 22:20:40.720509429 +0100 *************** *** 3574,3580 **** bufIsChanged(buf_T *buf) { #ifdef FEAT_TERMINAL ! if (term_job_running(buf->b_term)) return TRUE; #endif return bufIsChangedNotTerm(buf); --- 3574,3580 ---- bufIsChanged(buf_T *buf) { #ifdef FEAT_TERMINAL ! if (term_job_running_not_none(buf->b_term)) return TRUE; #endif return bufIsChangedNotTerm(buf); *** ../vim-8.2.5040/src/testdir/test_popupwin.vim 2022-05-29 18:17:57.130366124 +0100 --- src/testdir/test_popupwin.vim 2022-05-29 22:33:59.124422780 +0100 *************** *** 2880,2885 **** --- 2880,2903 ---- 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("\:q\", 'xt') + call assert_equal([], popup_list()) + + call assert_equal(origwin, win_getid()) + endfunc + func Test_popupwin_terminal_scrollbar() CheckFeature terminal CheckScreendump *** ../vim-8.2.5040/src/version.c 2022-05-29 18:17:57.130366124 +0100 --- src/version.c 2022-05-29 22:15:58.376786438 +0100 *************** *** 736,737 **** --- 736,739 ---- { /* Add new patch number below this line */ + /**/ + 5041, /**/ -- ARTHUR: Well, it doesn't matter. Will you go and tell your master that Arthur from the Court of Camelot is here. GUARD #1: Listen, in order to maintain air-speed velocity, a swallow needs to beat its wings 43 times every second, right? ARTHUR: Please! The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///