To: vim_dev@googlegroups.com Subject: Patch 8.1.0243 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0243 Problem: Using :term ++close ++hidden closes a window. (Marcin Szamotulski) Solution: Don't close the window if only using it temporarily for unloading the terminal buffer. (closes #3287) Files: src/terminal.c, src/testdir/test_terminal.vim *** ../vim-8.1.0242/src/terminal.c 2018-08-04 16:54:06.348012520 +0200 --- src/terminal.c 2018-08-07 16:27:03.373988690 +0200 *************** *** 2818,2828 **** if (term->tl_finish == TL_FINISH_CLOSE) { aco_save_T aco; ! /* ++close or term_finish == "close" */ ch_log(NULL, "terminal job finished, closing window"); aucmd_prepbuf(&aco, term->tl_buffer); do_bufdel(DOBUF_WIPE, (char_u *)"", 1, fnum, fnum, FALSE); aucmd_restbuf(&aco); return TRUE; } --- 2818,2834 ---- if (term->tl_finish == TL_FINISH_CLOSE) { aco_save_T aco; + int do_set_w_closing = term->tl_buffer->b_nwindows == 0; ! // ++close or term_finish == "close" ch_log(NULL, "terminal job finished, closing window"); aucmd_prepbuf(&aco, term->tl_buffer); + // Avoid closing the window if we temporarily use it. + if (do_set_w_closing) + curwin->w_closing = TRUE; do_bufdel(DOBUF_WIPE, (char_u *)"", 1, fnum, fnum, FALSE); + if (do_set_w_closing) + curwin->w_closing = FALSE; aucmd_restbuf(&aco); return TRUE; } *** ../vim-8.1.0242/src/testdir/test_terminal.vim 2018-08-04 16:54:06.348012520 +0200 --- src/testdir/test_terminal.vim 2018-08-07 16:32:04.084157368 +0200 *************** *** 1621,1623 **** --- 1621,1635 ---- call WaitForAssert({-> assert_equal('finished', term_getstatus(bnr))}) bwipe! endfunc + + func Test_terminal_hidden_and_close() + if !has('unix') + return + endif + call assert_equal(1, winnr('$')) + term ++hidden ++close ls + let bnr = bufnr('$') + call assert_equal('terminal', getbufvar(bnr, '&buftype')) + call WaitForAssert({-> assert_false(bufexists(bnr))}) + call assert_equal(1, winnr('$')) + endfunc *** ../vim-8.1.0242/src/version.c 2018-08-07 14:55:04.905259782 +0200 --- src/version.c 2018-08-07 16:28:42.681379863 +0200 *************** *** 796,797 **** --- 796,799 ---- { /* Add new patch number below this line */ + /**/ + 243, /**/ -- ARTHUR: Listen, old crone! Unless you tell us where we can buy a shrubbery, my friend and I will ... we will say "Ni!" CRONE: Do your worst! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///