summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0243
blob: 3a497d139595f7778a257d26d73da8bec7cfe367 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0243
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
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    ///