Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
19111:ca362df0be20 | 19112:0b337617877e |
---|---|
862 // 2: opened in curtab | 862 // 2: opened in curtab |
863 // 3: opened in curtab and curwin | 863 // 3: opened in curtab and curwin |
864 // | 864 // |
865 int opened_len; // length of opened[] | 865 int opened_len; // length of opened[] |
866 int use_firstwin = FALSE; // use first window for arglist | 866 int use_firstwin = FALSE; // use first window for arglist |
867 int tab_drop_empty_window = FALSE; | |
867 int split_ret = OK; | 868 int split_ret = OK; |
868 int p_ea_save; | 869 int p_ea_save; |
869 alist_T *alist; // argument list to be used | 870 alist_T *alist; // argument list to be used |
870 buf_T *buf; | 871 buf_T *buf; |
871 tabpage_T *tpnext; | 872 tabpage_T *tpnext; |
1025 ++autocmd_no_enter; | 1026 ++autocmd_no_enter; |
1026 ++autocmd_no_leave; | 1027 ++autocmd_no_leave; |
1027 last_curwin = curwin; | 1028 last_curwin = curwin; |
1028 last_curtab = curtab; | 1029 last_curtab = curtab; |
1029 win_enter(lastwin, FALSE); | 1030 win_enter(lastwin, FALSE); |
1030 // ":drop all" should re-use an empty window to avoid "--remote-tab" | 1031 // ":tab drop file" should re-use an empty window to avoid "--remote-tab" |
1031 // leaving an empty tab page when executed locally. | 1032 // leaving an empty tab page when executed locally. |
1032 if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1 | 1033 if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1 |
1033 && curbuf->b_ffname == NULL && !curbuf->b_changed) | 1034 && curbuf->b_ffname == NULL && !curbuf->b_changed) |
1035 { | |
1034 use_firstwin = TRUE; | 1036 use_firstwin = TRUE; |
1035 | 1037 tab_drop_empty_window = TRUE; |
1036 for (i = 0; i < count && i < opened_len && !got_int; ++i) | 1038 } |
1039 | |
1040 for (i = 0; i < count && !got_int; ++i) | |
1037 { | 1041 { |
1038 if (alist == &global_alist && i == global_alist.al_ga.ga_len - 1) | 1042 if (alist == &global_alist && i == global_alist.al_ga.ga_len - 1) |
1039 arg_had_last = TRUE; | 1043 arg_had_last = TRUE; |
1040 if (opened[i] > 0) | 1044 if (opened[i] > 0) |
1041 { | 1045 { |
1065 } | 1069 } |
1066 } | 1070 } |
1067 } | 1071 } |
1068 else if (split_ret == OK) | 1072 else if (split_ret == OK) |
1069 { | 1073 { |
1074 // trigger events for tab drop | |
1075 if (tab_drop_empty_window && i == count - 1) | |
1076 --autocmd_no_enter; | |
1070 if (!use_firstwin) // split current window | 1077 if (!use_firstwin) // split current window |
1071 { | 1078 { |
1072 p_ea_save = p_ea; | 1079 p_ea_save = p_ea; |
1073 p_ea = TRUE; // use space from all windows | 1080 p_ea = TRUE; // use space from all windows |
1074 split_ret = win_split(0, WSP_ROOM | WSP_BELOW); | 1081 split_ret = win_split(0, WSP_ROOM | WSP_BELOW); |
1089 (void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL, | 1096 (void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL, |
1090 ECMD_ONE, | 1097 ECMD_ONE, |
1091 ((buf_hide(curwin->w_buffer) | 1098 ((buf_hide(curwin->w_buffer) |
1092 || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) | 1099 || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) |
1093 + ECMD_OLDBUF, curwin); | 1100 + ECMD_OLDBUF, curwin); |
1101 if (tab_drop_empty_window && i == count - 1) | |
1102 ++autocmd_no_enter; | |
1094 if (use_firstwin) | 1103 if (use_firstwin) |
1095 ++autocmd_no_leave; | 1104 ++autocmd_no_leave; |
1096 use_firstwin = FALSE; | 1105 use_firstwin = FALSE; |
1097 } | 1106 } |
1098 ui_breakcheck(); | 1107 ui_breakcheck(); |