Mercurial > vim
diff src/window.c @ 9595:0190d5de215f v7.4.2075
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jul 19 22:31:36 2016 +0200
patch 7.4.2075
Problem: No autocommand event to initialize a window or tab page.
Solution: Add WinNew and TabNew events. (partly by Felipe Morales)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 19 Jul 2016 22:45:05 +0200 |
parents | 69ed2c9d34a6 |
children | 42a8a81decdf |
line wrap: on
line diff
--- a/src/window.c +++ b/src/window.c @@ -45,7 +45,7 @@ static int leave_tabpage(buf_T *new_curb static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_autocmds, int trigger_leave_autocmds); static void frame_fix_height(win_T *wp); static int frame_minheight(frame_T *topfrp, win_T *next_curwin); -static void win_enter_ext(win_T *wp, int undo_sync, int no_curwin, int trigger_enter_autocmds, int trigger_leave_autocmds); +static void win_enter_ext(win_T *wp, int undo_sync, int no_curwin, int trigger_new_autocmds, int trigger_enter_autocmds, int trigger_leave_autocmds); static void win_free(win_T *wp, tabpage_T *tp); static void frame_append(frame_T *after, frame_T *frp); static void frame_insert(frame_T *before, frame_T *frp); @@ -1259,7 +1259,7 @@ win_split_ins( /* * make the new window the current window */ - win_enter(wp, FALSE); + win_enter_ext(wp, FALSE, FALSE, TRUE, TRUE, TRUE); if (flags & WSP_VERT) p_wiw = i; else @@ -2416,7 +2416,7 @@ win_close(win_T *win, int free_buf) win_comp_pos(); if (close_curwin) { - win_enter_ext(wp, FALSE, TRUE, TRUE, TRUE); + win_enter_ext(wp, FALSE, TRUE, FALSE, TRUE, TRUE); #ifdef FEAT_AUTOCMD if (other_buffer) /* careful: after this wp and win may be invalid! */ @@ -3629,7 +3629,9 @@ win_new_tabpage(int after) redraw_all_later(CLEAR); #ifdef FEAT_AUTOCMD + apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); + apply_autocmds(EVENT_TABNEW, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); #endif return OK; @@ -3808,7 +3810,7 @@ enter_tabpage( /* We would like doing the TabEnter event first, but we don't have a * valid current window yet, which may break some commands. * This triggers autocommands, thus may make "tp" invalid. */ - win_enter_ext(tp->tp_curwin, FALSE, TRUE, + win_enter_ext(tp->tp_curwin, FALSE, TRUE, FALSE, trigger_enter_autocmds, trigger_leave_autocmds); prevwin = next_prevwin; @@ -4242,7 +4244,7 @@ end: void win_enter(win_T *wp, int undo_sync) { - win_enter_ext(wp, undo_sync, FALSE, TRUE, TRUE); + win_enter_ext(wp, undo_sync, FALSE, FALSE, TRUE, TRUE); } /* @@ -4255,6 +4257,7 @@ win_enter_ext( win_T *wp, int undo_sync, int curwin_invalid, + int trigger_new_autocmds UNUSED, int trigger_enter_autocmds UNUSED, int trigger_leave_autocmds UNUSED) { @@ -4340,6 +4343,8 @@ win_enter_ext( } #ifdef FEAT_AUTOCMD + if (trigger_new_autocmds) + apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); if (trigger_enter_autocmds) { apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);