]> granicus.if.org Git - vim/commitdiff
patch 8.0.1328: trouble when using ":term ++close" with autocmd v8.0.1328
authorBram Moolenaar <Bram@vim.org>
Tue, 21 Nov 2017 13:47:57 +0000 (14:47 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 21 Nov 2017 13:47:57 +0000 (14:47 +0100)
Problem:    Trouble when using ":term ++close" with autocmd. (Gabriel Barta)
Solution:   Use aucmd_prepbuf() and aucmd_restbuf() instead of setting curbuf.
            (closes #2339)

src/terminal.c
src/testdir/test_terminal.vim
src/version.c

index a4caa42edab5730f9e9860b31d621538894a6c4a..2e6b399184acc88ccb7c9b2d0c968da5e004294f 100644 (file)
@@ -51,6 +51,7 @@
  * - implement term_setsize()
  * - Termdebug does not work when Vim build with mzscheme.  gdb hangs.
  * - MS-Windows GUI: WinBar has  tearoff item
+ * - Adding WinBar to terminal window doesn't display, text isn't shifted down.
  * - MS-Windows GUI: still need to type a key after shell exits?  #1924
  * - After executing a shell command the status line isn't redraw.
  * - What to store in a session file?  Shell at the prompt would be OK to
@@ -2172,10 +2173,13 @@ term_channel_closed(channel_T *ch)
 
                if (term->tl_finish == 'c')
                {
+                   aco_save_T  aco;
+
                    /* ++close or term_finish == "close" */
                    ch_log(NULL, "terminal job finished, closing window");
-                   curbuf = term->tl_buffer;
+                   aucmd_prepbuf(&aco, term->tl_buffer);
                    do_bufdel(DOBUF_WIPE, (char_u *)"", 1, fnum, fnum, FALSE);
+                   aucmd_restbuf(&aco);
                    break;
                }
                if (term->tl_finish == 'o' && term->tl_buffer->b_nwindows == 0)
index 4d20794eac7e24916ebcfa06653f719a6b3b9d5f..295ccf1c9682a967eb27ad170559a55ef0c0ec46 100644 (file)
@@ -352,9 +352,7 @@ func Test_terminal_curwin()
   call delete('Xtext')
 endfunc
 
-func Test_finish_open_close()
-  call assert_equal(1, winnr('$'))
-
+func s:get_sleep_cmd()
   if s:python != ''
     let cmd = s:python . " test_short_sleep.py"
     let waittime = 500
@@ -367,12 +365,18 @@ func Test_finish_open_close()
       let cmd = 'sleep 1'
     endif
   endif
+  return [cmd, waittime]
+endfunc
+
+func Test_terminal_finish_open_close()
+  call assert_equal(1, winnr('$'))
+
+  let [cmd, waittime] = s:get_sleep_cmd()
 
   exe 'terminal ++close ' . cmd
   call assert_equal(2, winnr('$'))
   wincmd p
   call WaitFor("winnr('$') == 1", waittime)
-  call assert_equal(1, winnr('$'))
 
   call term_start(cmd, {'term_finish': 'close'})
   call assert_equal(2, winnr('$'))
@@ -743,3 +747,29 @@ func Test_terminal_composing_unicode()
   unlet g:job
   let &encoding = save_enc
 endfunc
+
+func Test_terminal_aucmd_on_close()
+  fun Nop()
+    let s:called = 1
+  endfun
+
+  aug repro
+      au!
+      au BufWinLeave * call Nop()
+  aug END
+
+  let [cmd, waittime] = s:get_sleep_cmd()
+
+  call assert_equal(1, winnr('$'))
+  new
+  call setline(1, ['one', 'two'])
+  exe 'term ++close ' . cmd
+  wincmd p
+  call WaitFor("winnr('$') == 2", waittime)
+  call assert_equal(1, s:called)
+  bwipe!
+
+  unlet s:called
+  au! repro
+  delfunc Nop
+endfunc
index 9df29eb7d085c9ca92ecb292b7e16577257be453..d311de91bc9f8e7fb10572b808c0f4b6828d2b92 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1328,
 /**/
     1327,
 /**/