To: vim_dev@googlegroups.com Subject: Patch 8.0.1720 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1720 Problem: When a timer is running a terminal window may not close after a shell has exited. Solution: Call job_status() more often. Files: src/terminal.c *** ../vim-8.0.1719/src/terminal.c 2018-04-15 12:55:09.331988871 +0200 --- src/terminal.c 2018-04-15 17:03:39.155823711 +0200 *************** *** 40,56 **** * TODO: * - Win32: Make terminal used for :!cmd in the GUI work better. Allow for * redirection. Probably in call to channel_set_pipes(). * - Copy text in the vterm to the Vim buffer once in a while, so that * completion works. * - in GUI vertical split causes problems. Cursor is flickering. (Hirohito * Higashi, 2017 Sep 19) * - after resizing windows overlap. (Boris Staletic, #2164) - * - Redirecting output does not work on MS-Windows, Test_terminal_redir_file() - * is disabled. * - cursor blinks in terminal on widows with a timer. (xtal8, #2142) * - Termdebug does not work when Vim build with mzscheme. gdb hangs. - * - MS-Windows GUI: WinBar has tearoff item - * - MS-Windows GUI: still need to type a key after shell exits? #1924 * - After executing a shell command the status line isn't redraw. * - add test for giving error for invalid 'termsize' value. * - support minimal size when 'termsize' is "rows*cols". --- 40,57 ---- * TODO: * - Win32: Make terminal used for :!cmd in the GUI work better. Allow for * redirection. Probably in call to channel_set_pipes(). + * - Win32: Redirecting output does not work, Test_terminal_redir_file() + * is disabled. * - Copy text in the vterm to the Vim buffer once in a while, so that * completion works. + * - When starting terminal window with shell in terminal, then using :gui to + * switch to GUI, shell stops working. Scrollback seems wrong, command + * running in shell is still running. * - in GUI vertical split causes problems. Cursor is flickering. (Hirohito * Higashi, 2017 Sep 19) * - after resizing windows overlap. (Boris Staletic, #2164) * - cursor blinks in terminal on widows with a timer. (xtal8, #2142) * - Termdebug does not work when Vim build with mzscheme. gdb hangs. * - After executing a shell command the status line isn't redraw. * - add test for giving error for invalid 'termsize' value. * - support minimal size when 'termsize' is "rows*cols". *************** *** 59,65 **** * - Redrawing is slow with Athena and Motif. Also other GUI? (Ramel Eshed) * - For the GUI fill termios with default values, perhaps like pangoterm: * http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134 ! * - when 'encoding' is not utf-8, or the job is using another encoding, setup * conversions. */ --- 60,66 ---- * - Redrawing is slow with Athena and Motif. Also other GUI? (Ramel Eshed) * - For the GUI fill termios with default values, perhaps like pangoterm: * http://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/head:/main.c#L134 ! * - When 'encoding' is not utf-8, or the job is using another encoding, setup * conversions. */ *************** *** 1223,1239 **** /* * Return TRUE if the job for "term" is still running. */ ! int ! term_job_running(term_T *term) { /* Also consider the job finished when the channel is closed, to avoid a * race condition when updating the title. */ ! return term != NULL && term->tl_job != NULL ! && channel_is_open(term->tl_job->jv_channel) ! && (term->tl_job->jv_status == JOB_STARTED || term->tl_job->jv_channel->ch_keep_open); } /* --- 1224,1255 ---- /* * Return TRUE if the job for "term" is still running. + * If "check_job_status" is TRUE update the job status. */ ! static int ! term_job_running_check(term_T *term, int check_job_status) { /* Also consider the job finished when the channel is closed, to avoid a * race condition when updating the title. */ ! if (term != NULL && term->tl_job != NULL ! && channel_is_open(term->tl_job->jv_channel)) ! { ! if (check_job_status) ! job_status(term->tl_job); ! return (term->tl_job->jv_status == JOB_STARTED || term->tl_job->jv_channel->ch_keep_open); + } + return FALSE; + } + + /* + * Return TRUE if the job for "term" is still running. + */ + int + term_job_running(term_T *term) + { + return term_job_running_check(term, FALSE); } /* *************** *** 1892,1897 **** --- 1908,1939 ---- } /* + * Returns TRUE if the current window contains a terminal and we are sending + * keys to the job. + * If "check_job_status" is TRUE update the job status. + */ + static int + term_use_loop_check(int check_job_status) + { + term_T *term = curbuf->b_term; + + return term != NULL + && !term->tl_normal_mode + && term->tl_vterm != NULL + && term_job_running_check(term, check_job_status); + } + + /* + * Returns TRUE if the current window contains a terminal and we are sending + * keys to the job. + */ + int + term_use_loop(void) + { + return term_use_loop_check(FALSE); + } + + /* * Called when entering a window with the mouse. If this is a terminal window * we may want to change state. */ *************** *** 1902,1908 **** if (term != NULL) { ! if (term_use_loop()) { reset_VIsual_and_resel(); if (State & INSERT) --- 1944,1950 ---- if (term != NULL) { ! if (term_use_loop_check(TRUE)) { reset_VIsual_and_resel(); if (State & INSERT) *************** *** 1915,1935 **** } /* - * Returns TRUE if the current window contains a terminal and we are sending - * keys to the job. - */ - int - term_use_loop(void) - { - term_T *term = curbuf->b_term; - - return term != NULL - && !term->tl_normal_mode - && term->tl_vterm != NULL - && term_job_running(term); - } - - /* * Wait for input and send it to the job. * When "blocking" is TRUE wait for a character to be typed. Otherwise return * when there is no more typahead. --- 1957,1962 ---- *************** *** 1976,1982 **** restore_cursor = TRUE; c = term_vgetc(); ! if (!term_use_loop()) { /* Job finished while waiting for a character. Push back the * received character. */ --- 2003,2009 ---- restore_cursor = TRUE; c = term_vgetc(); ! if (!term_use_loop_check(TRUE)) { /* Job finished while waiting for a character. Push back the * received character. */ *************** *** 2027,2033 **** #ifdef FEAT_CMDL_INFO clear_showcmd(); #endif ! if (!term_use_loop()) /* job finished while waiting for a character */ break; --- 2054,2060 ---- #ifdef FEAT_CMDL_INFO clear_showcmd(); #endif ! if (!term_use_loop_check(TRUE)) /* job finished while waiting for a character */ break; *** ../vim-8.0.1719/src/version.c 2018-04-15 16:03:12.775985408 +0200 --- src/version.c 2018-04-15 17:19:34.401164855 +0200 *************** *** 764,765 **** --- 764,767 ---- { /* Add new patch number below this line */ + /**/ + 1720, /**/ -- I'm in shape. Round IS a shape. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///