diff src/arglist.c @ 19112:0b337617877e v8.2.0116

patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop" Commit: https://github.com/vim/vim/commit/c10b521628f2b073fa231defa26f23937c91724d Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 13 20:54:51 2020 +0100 patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop" Problem: BufEnter autocmd not triggered on ":tab drop". (Andy Stewart) Solution: Decrement autocmd_no_enter for the last file. (closes https://github.com/vim/vim/issues/1660, closes #5473)
author Bram Moolenaar <Bram@vim.org>
date Mon, 13 Jan 2020 21:00:03 +0100
parents 04245f071792
children ebeeb4b4a1fa
line wrap: on
line diff
--- a/src/arglist.c
+++ b/src/arglist.c
@@ -864,6 +864,7 @@ do_arg_all(
 				//
     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,13 +1028,16 @@ do_arg_all(
     last_curwin = curwin;
     last_curtab = curtab;
     win_enter(lastwin, FALSE);
-    // ":drop all" should re-use an empty window to avoid "--remote-tab"
+    // ":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 && i < opened_len && !got_int; ++i)
+    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,6 +1071,9 @@ do_arg_all(
 	}
 	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,6 +1098,8 @@ do_arg_all(
 		      ((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;