Patch 8.2.3286

3 views
Skip to first unread message

Bram Moolenaar

unread,
Aug 4, 2021, 2:26:55 PM8/4/21
to vim...@googlegroups.com

Patch 8.2.3286
Problem: win_enter_ext() has too many boolean arguments.
Solution: use one flags argument with defined values.
Files: src/window.c


*** ../vim-8.2.3285/src/window.c 2021-07-20 21:07:32.972058844 +0200
--- src/window.c 2021-08-04 20:23:44.342586053 +0200
***************
*** 40,46 ****
static void frame_fix_height(win_T *wp);
static int frame_minheight(frame_T *topfrp, win_T *next_curwin);
static int may_open_tabpage(void);
! 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 int win_unlisted(win_T *wp);
static void win_append(win_T *after, win_T *wp);
--- 40,46 ----
static void frame_fix_height(win_T *wp);
static int frame_minheight(frame_T *topfrp, win_T *next_curwin);
static int may_open_tabpage(void);
! static void win_enter_ext(win_T *wp, int flags);
static void win_free(win_T *wp, tabpage_T *tp);
static int win_unlisted(win_T *wp);
static void win_append(win_T *after, win_T *wp);
***************
*** 67,72 ****
--- 67,79 ----

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

+ // flags for win_enter_ext()
+ #define WEE_UNDO_SYNC 0x01
+ #define WEE_CURWIN_INVALID 0x02
+ #define WEE_TRIGGER_NEW_AUTOCMDS 0x04
+ #define WEE_TRIGGER_ENTER_AUTOCMDS 0x08
+ #define WEE_TRIGGER_LEAVE_AUTOCMDS 0x10
+
static char *m_onlyone = N_("Already only one window");

// When non-zero splitting a window is forbidden. Used to avoid that nasty
***************
*** 1331,1337 ****
/*
* make the new window the current window
*/
! win_enter_ext(wp, FALSE, FALSE, TRUE, TRUE, TRUE);
if (flags & WSP_VERT)
p_wiw = i;
else
--- 1338,1345 ----
/*
* make the new window the current window
*/
! win_enter_ext(wp, WEE_TRIGGER_NEW_AUTOCMDS | WEE_TRIGGER_ENTER_AUTOCMDS
! | WEE_TRIGGER_LEAVE_AUTOCMDS);
if (flags & WSP_VERT)
p_wiw = i;
else
***************
*** 2653,2659 ****
win_comp_pos();
if (close_curwin)
{
! win_enter_ext(wp, FALSE, TRUE, FALSE, TRUE, TRUE);
if (other_buffer)
// careful: after this wp and win may be invalid!
apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
--- 2661,2668 ----
win_comp_pos();
if (close_curwin)
{
! win_enter_ext(wp, WEE_CURWIN_INVALID | WEE_TRIGGER_ENTER_AUTOCMDS
! | WEE_TRIGGER_LEAVE_AUTOCMDS);
if (other_buffer)
// careful: after this wp and win may be invalid!
apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
***************
*** 4179,4186 ****
// 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, FALSE,
! trigger_enter_autocmds, trigger_leave_autocmds);
prevwin = next_prevwin;

last_status(FALSE); // status line may appear or disappear
--- 4188,4196 ----
// 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, WEE_CURWIN_INVALID
! | (trigger_enter_autocmds ? WEE_TRIGGER_ENTER_AUTOCMDS : 0)
! | (trigger_leave_autocmds ? WEE_TRIGGER_LEAVE_AUTOCMDS : 0));
prevwin = next_prevwin;

last_status(FALSE); // status line may appear or disappear
***************
*** 4679,4702 ****
void
win_enter(win_T *wp, int undo_sync)
{
! win_enter_ext(wp, undo_sync, FALSE, FALSE, TRUE, TRUE);
}

/*
! * Make window wp the current window.
! * Can be called with "curwin_invalid" TRUE, which means that curwin has just
! * been closed and isn't valid.
*/
static void
! win_enter_ext(
! win_T *wp,
! int undo_sync,
! int curwin_invalid,
! int trigger_new_autocmds,
! int trigger_enter_autocmds,
! int trigger_leave_autocmds)
{
int other_buffer = FALSE;

if (wp == curwin && !curwin_invalid) // nothing to do
return;
--- 4689,4708 ----
void
win_enter(win_T *wp, int undo_sync)
{
! win_enter_ext(wp, (undo_sync ? WEE_UNDO_SYNC : 0)
! | WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS);
}

/*
! * Make window "wp" the current window.
! * Can be called with "flags" containing WEE_CURWIN_INVALID, which means that
! * curwin has just been closed and isn't valid.
*/
static void
! win_enter_ext(win_T *wp, int flags)
{
int other_buffer = FALSE;
+ int curwin_invalid = (flags & WEE_CURWIN_INVALID);

if (wp == curwin && !curwin_invalid) // nothing to do
return;
***************
*** 4706,4712 ****
leaving_window(curwin);
#endif

! if (!curwin_invalid && trigger_leave_autocmds)
{
/*
* Be careful: If autocommands delete the window, return now.
--- 4712,4718 ----
leaving_window(curwin);
#endif

! if (!curwin_invalid && (flags & WEE_TRIGGER_LEAVE_AUTOCMDS))
{
/*
* Be careful: If autocommands delete the window, return now.
***************
*** 4729,4735 ****
}

// sync undo before leaving the current buffer
! if (undo_sync && curbuf != wp->w_buffer)
u_sync(FALSE);

// Might need to scroll the old window before switching, e.g., when the
--- 4735,4741 ----
}

// sync undo before leaving the current buffer
! if ((flags & WEE_UNDO_SYNC) && curbuf != wp->w_buffer)
u_sync(FALSE);

// Might need to scroll the old window before switching, e.g., when the
***************
*** 4786,4794 ****
entering_window(curwin);
#endif
// Careful: autocommands may close the window and make "wp" invalid
! if (trigger_new_autocmds)
apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
! if (trigger_enter_autocmds)
{
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
if (other_buffer)
--- 4792,4800 ----
entering_window(curwin);
#endif
// Careful: autocommands may close the window and make "wp" invalid
! if (flags & WEE_TRIGGER_NEW_AUTOCMDS)
apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
! if (flags & WEE_TRIGGER_ENTER_AUTOCMDS)
{
apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
if (other_buffer)
*** ../vim-8.2.3285/src/version.c 2021-08-04 20:00:24.413671050 +0200
--- src/version.c 2021-08-04 20:24:31.610483081 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3286,
/**/

--
GUARD #1: What -- a swallow carrying a coconut?
ARTHUR: It could grip it by the husk!
GUARD #1: It's not a question of where he grips it! It's a simple question
of weight ratios! A five ounce bird could not carry a 1 pound
coconut.
The Quest for the Holy Grail (Monty Python)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages