Patch 8.2.0116
Problem:    BufEnter autocmd not triggered on ":tab drop". (Andy Stewart)
Solution:   Decrement autocmd_no_enter for the last file. (closes #1660,
            closes #5473)
Files:      src/arglist.c, src/testdir/test_tabpage.vim


*** ../vim-8.2.0115/src/arglist.c       2019-08-18 22:06:34.000000000 +0200
--- src/arglist.c       2020-01-13 20:50:28.300577815 +0100
***************
*** 864,869 ****
--- 864,870 ----
                                //
      int               opened_len;     // length of opened[]
      int               use_firstwin = FALSE;   // use first window for arglist
+     int               tab_drop_empty_window = FALSE;
      int               split_ret = OK;
      int               p_ea_save;
      alist_T   *alist;         // argument list to be used
***************
*** 1027,1039 ****
      last_curwin = curwin;
      last_curtab = curtab;
      win_enter(lastwin, FALSE);
!     // ":drop all" should re-use an empty window to avoid "--remote-tab"
      // leaving an empty tab page when executed locally.
      if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1
                            && curbuf->b_ffname == NULL && !curbuf->b_changed)
        use_firstwin = TRUE;
  
!     for (i = 0; i < count && i < opened_len && !got_int; ++i)
      {
        if (alist == &global_alist && i == global_alist.al_ga.ga_len - 1)
            arg_had_last = TRUE;
--- 1028,1043 ----
      last_curwin = curwin;
      last_curtab = curtab;
      win_enter(lastwin, FALSE);
!     // ":tab drop file" should re-use an empty window to avoid "--remote-tab"
      // leaving an empty tab page when executed locally.
      if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1
                            && curbuf->b_ffname == NULL && !curbuf->b_changed)
+     {
        use_firstwin = TRUE;
+       tab_drop_empty_window = TRUE;
+     }
  
!     for (i = 0; i < count && !got_int; ++i)
      {
        if (alist == &global_alist && i == global_alist.al_ga.ga_len - 1)
            arg_had_last = TRUE;
***************
*** 1067,1072 ****
--- 1071,1079 ----
        }
        else if (split_ret == OK)
        {
+           // trigger events for tab drop
+           if (tab_drop_empty_window && i == count - 1)
+               --autocmd_no_enter;
            if (!use_firstwin)          // split current window
            {
                p_ea_save = p_ea;
***************
*** 1091,1096 ****
--- 1098,1105 ----
                      ((buf_hide(curwin->w_buffer)
                           || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0)
                                                       + ECMD_OLDBUF, curwin);
+           if (tab_drop_empty_window && i == count - 1)
+               ++autocmd_no_enter;
            if (use_firstwin)
                ++autocmd_no_leave;
            use_firstwin = FALSE;
*** ../vim-8.2.0115/src/testdir/test_tabpage.vim        2019-12-01 
14:54:09.000000000 +0100
--- src/testdir/test_tabpage.vim        2020-01-13 20:50:28.300577815 +0100
***************
*** 222,227 ****
--- 222,255 ----
    1tabonly!
  endfunction
  
+ " Test autocommands on tab drop
+ function Test_tabpage_with_autocmd_tab_drop()
+   augroup TestTabpageGroup
+     au!
+     autocmd TabEnter * call add(s:li, 'TabEnter')
+     autocmd WinEnter * call add(s:li, 'WinEnter')
+     autocmd BufEnter * call add(s:li, 'BufEnter')
+     autocmd TabLeave * call add(s:li, 'TabLeave')
+     autocmd WinLeave * call add(s:li, 'WinLeave')
+     autocmd BufLeave * call add(s:li, 'BufLeave')
+   augroup END
+ 
+   let s:li = []
+   tab drop test1
+   call assert_equal(['BufLeave', 'BufEnter'], s:li)
+ 
+   let s:li = []
+   tab drop test2 test3
+   call assert_equal([
+         \ 'TabLeave', 'TabEnter', 'TabLeave', 'TabEnter',
+         \ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter',
+         \ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter'], s:li)
+ 
+   autocmd! TestTabpageGroup
+   augroup! TestTabpageGroup
+   1tabonly!
+ endfunction
+ 
  function Test_tabpage_with_tab_modifier()
    CheckFeature quickfix
  
*** ../vim-8.2.0115/src/version.c       2020-01-13 20:40:47.694773941 +0100
--- src/version.c       2020-01-13 20:54:26.183690393 +0100
***************
*** 744,745 ****
--- 744,747 ----
  {   /* Add new patch number below this line */
+ /**/
+     116,
  /**/

-- 
TERRY GILLIAM PLAYED: PATSY (ARTHUR'S TRUSTY STEED), THE GREEN KNIGHT
                      SOOTHSAYER, BRIDGEKEEPER, SIR GAWAIN (THE FIRST TO BE
                      KILLED BY THE RABBIT)
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- 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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202001131955.00DJtgDe025887%40masaka.moolenaar.net.

Raspunde prin e-mail lui