1
0
forked from aniani/vim

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)
This commit is contained in:
Bram Moolenaar
2016-07-19 22:31:36 +02:00
parent 0a0f641b98
commit c917da4b3e
6 changed files with 56 additions and 6 deletions

View File

@@ -45,7 +45,7 @@ static int leave_tabpage(buf_T *new_curbuf, int trigger_leave_autocmds);
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);