Skip to content

Commit d61f2f7

Browse files
committed
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Problem: win_enter_ext() has too many boolean arguments. Solution: use one flags argument with defined values.
1 parent dd097bd commit d61f2f7

2 files changed

Lines changed: 28 additions & 20 deletions

File tree

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3286,
758760
/**/
759761
3285,
760762
/**/

src/window.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_au
4040
static void frame_fix_height(win_T *wp);
4141
static int frame_minheight(frame_T *topfrp, win_T *next_curwin);
4242
static int may_open_tabpage(void);
43-
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);
43+
static void win_enter_ext(win_T *wp, int flags);
4444
static void win_free(win_T *wp, tabpage_T *tp);
4545
static int win_unlisted(win_T *wp);
4646
static void win_append(win_T *after, win_T *wp);
@@ -67,6 +67,13 @@ static win_T *win_alloc(win_T *after, int hidden);
6767

6868
#define ROWS_AVAIL (Rows - p_ch - tabline_height())
6969

70+
// flags for win_enter_ext()
71+
#define WEE_UNDO_SYNC 0x01
72+
#define WEE_CURWIN_INVALID 0x02
73+
#define WEE_TRIGGER_NEW_AUTOCMDS 0x04
74+
#define WEE_TRIGGER_ENTER_AUTOCMDS 0x08
75+
#define WEE_TRIGGER_LEAVE_AUTOCMDS 0x10
76+
7077
static char *m_onlyone = N_("Already only one window");
7178

7279
// When non-zero splitting a window is forbidden. Used to avoid that nasty
@@ -1331,7 +1338,8 @@ win_split_ins(
13311338
/*
13321339
* make the new window the current window
13331340
*/
1334-
win_enter_ext(wp, FALSE, FALSE, TRUE, TRUE, TRUE);
1341+
win_enter_ext(wp, WEE_TRIGGER_NEW_AUTOCMDS | WEE_TRIGGER_ENTER_AUTOCMDS
1342+
| WEE_TRIGGER_LEAVE_AUTOCMDS);
13351343
if (flags & WSP_VERT)
13361344
p_wiw = i;
13371345
else
@@ -2653,7 +2661,8 @@ win_close(win_T *win, int free_buf)
26532661
win_comp_pos();
26542662
if (close_curwin)
26552663
{
2656-
win_enter_ext(wp, FALSE, TRUE, FALSE, TRUE, TRUE);
2664+
win_enter_ext(wp, WEE_CURWIN_INVALID | WEE_TRIGGER_ENTER_AUTOCMDS
2665+
| WEE_TRIGGER_LEAVE_AUTOCMDS);
26572666
if (other_buffer)
26582667
// careful: after this wp and win may be invalid!
26592668
apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
@@ -4179,8 +4188,9 @@ enter_tabpage(
41794188
// We would like doing the TabEnter event first, but we don't have a
41804189
// valid current window yet, which may break some commands.
41814190
// This triggers autocommands, thus may make "tp" invalid.
4182-
win_enter_ext(tp->tp_curwin, FALSE, TRUE, FALSE,
4183-
trigger_enter_autocmds, trigger_leave_autocmds);
4191+
win_enter_ext(tp->tp_curwin, WEE_CURWIN_INVALID
4192+
| (trigger_enter_autocmds ? WEE_TRIGGER_ENTER_AUTOCMDS : 0)
4193+
| (trigger_leave_autocmds ? WEE_TRIGGER_LEAVE_AUTOCMDS : 0));
41844194
prevwin = next_prevwin;
41854195

41864196
last_status(FALSE); // status line may appear or disappear
@@ -4679,24 +4689,20 @@ win_goto_hor(
46794689
void
46804690
win_enter(win_T *wp, int undo_sync)
46814691
{
4682-
win_enter_ext(wp, undo_sync, FALSE, FALSE, TRUE, TRUE);
4692+
win_enter_ext(wp, (undo_sync ? WEE_UNDO_SYNC : 0)
4693+
| WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS);
46834694
}
46844695

46854696
/*
4686-
* Make window wp the current window.
4687-
* Can be called with "curwin_invalid" TRUE, which means that curwin has just
4688-
* been closed and isn't valid.
4697+
* Make window "wp" the current window.
4698+
* Can be called with "flags" containing WEE_CURWIN_INVALID, which means that
4699+
* curwin has just been closed and isn't valid.
46894700
*/
46904701
static void
4691-
win_enter_ext(
4692-
win_T *wp,
4693-
int undo_sync,
4694-
int curwin_invalid,
4695-
int trigger_new_autocmds,
4696-
int trigger_enter_autocmds,
4697-
int trigger_leave_autocmds)
4702+
win_enter_ext(win_T *wp, int flags)
46984703
{
46994704
int other_buffer = FALSE;
4705+
int curwin_invalid = (flags & WEE_CURWIN_INVALID);
47004706

47014707
if (wp == curwin && !curwin_invalid) // nothing to do
47024708
return;
@@ -4706,7 +4712,7 @@ win_enter_ext(
47064712
leaving_window(curwin);
47074713
#endif
47084714

4709-
if (!curwin_invalid && trigger_leave_autocmds)
4715+
if (!curwin_invalid && (flags & WEE_TRIGGER_LEAVE_AUTOCMDS))
47104716
{
47114717
/*
47124718
* Be careful: If autocommands delete the window, return now.
@@ -4729,7 +4735,7 @@ win_enter_ext(
47294735
}
47304736

47314737
// sync undo before leaving the current buffer
4732-
if (undo_sync && curbuf != wp->w_buffer)
4738+
if ((flags & WEE_UNDO_SYNC) && curbuf != wp->w_buffer)
47334739
u_sync(FALSE);
47344740

47354741
// Might need to scroll the old window before switching, e.g., when the
@@ -4786,9 +4792,9 @@ win_enter_ext(
47864792
entering_window(curwin);
47874793
#endif
47884794
// Careful: autocommands may close the window and make "wp" invalid
4789-
if (trigger_new_autocmds)
4795+
if (flags & WEE_TRIGGER_NEW_AUTOCMDS)
47904796
apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
4791-
if (trigger_enter_autocmds)
4797+
if (flags & WEE_TRIGGER_ENTER_AUTOCMDS)
47924798
{
47934799
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
47944800
if (other_buffer)

0 commit comments

Comments
 (0)