vim-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.
d61f2f772a

Include some style changes to appease the linter.

N/A patches for version.c:

vim-patch:8.2.3289: compiler warning for unused variable with small features

Problem:    Compiler warning for unused variable with small features.
Solution:   Rearrange #ifdefs.
f18e8a969a

vim-patch:8.2.3298: build failure with small features

Problem:    Build failure with small features.
Solution:   Add #ifdef.
6f6d58c380

vim-patch:8.2.3331: Coverity warns for using value without boundary check

Problem:    Coverity warns for using value without boundary check.
Solution:   Add a boundary check.
ed7cb2df35

vim-patch:8.2.3354: build failure with +byte_offset but without +textprop

Problem:    Build failure with +byte_offset but without +textprop. (John
            Marriott)
Solution:   Adjust the #ifdef.
92755bba30

vim-patch:8.2.3355: MS-Windows: compiler warning for 64-32 bit conversion

Problem:    MS-Windows: compiler warning for 64-32 bit conversion.
Solution:   Add type casts.
434df7a401
This commit is contained in:
Sean Dewar 2021-08-21 16:44:27 +01:00
parent c2a65921d7
commit 7ff5f02821
No known key found for this signature in database
GPG Key ID: 08CC2C83AD41B581

View File

@ -64,6 +64,14 @@
# define ROWS_AVAIL (Rows - p_ch - tabline_height())
/// flags for win_enter_ext()
typedef enum {
WEE_UNDO_SYNC = 0x01,
WEE_CURWIN_INVALID = 0x02,
WEE_TRIGGER_NEW_AUTOCMDS = 0x04,
WEE_TRIGGER_ENTER_AUTOCMDS = 0x08,
WEE_TRIGGER_LEAVE_AUTOCMDS = 0x10,
} wee_flags_T;
static char *m_onlyone = N_("Already only one window");
@ -1397,10 +1405,9 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
// Keep same changelist position in new window.
wp->w_changelistidx = oldwin->w_changelistidx;
/*
* make the new window the current window
*/
win_enter_ext(wp, false, false, true, true, true);
// 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 {
@ -2620,7 +2627,8 @@ int win_close(win_T *win, bool free_buf)
}
if (close_curwin) {
win_enter_ext(wp, false, true, false, true, true);
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);
@ -4005,11 +4013,12 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, bool trigger_enter_a
tabpage_check_windows(old_curtab);
}
/* 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);
// 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
@ -4462,26 +4471,25 @@ static void win_goto_hor(bool left, long count)
/// win_valid(wp).
void win_enter(win_T *wp, bool undo_sync)
{
win_enter_ext(wp, undo_sync, false, false, true, true);
win_enter_ext(wp, (undo_sync ? WEE_UNDO_SYNC : 0)
| WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS);
}
/// Make window wp the current window.
/// Make window "wp" the current window.
///
/// @param curwin_invalid curwin has just been closed and
/// isn't valid when true.
static void win_enter_ext(win_T *wp, bool undo_sync, bool curwin_invalid, bool trigger_new_autocmds,
bool trigger_enter_autocmds, bool trigger_leave_autocmds)
/// @param flags if contains WEE_CURWIN_INVALID, it means curwin has just been
/// closed and isn't valid.
static void win_enter_ext(win_T *const wp, const int flags)
{
bool other_buffer = false;
const bool curwin_invalid = (flags & WEE_CURWIN_INVALID);
if (wp == curwin && !curwin_invalid) { // nothing to do
return;
}
if (!curwin_invalid && trigger_leave_autocmds) {
/*
* Be careful: If autocommands delete the window, return now.
*/
if (!curwin_invalid && (flags & WEE_TRIGGER_LEAVE_AUTOCMDS)) {
// Be careful: If autocommands delete the window, return now.
if (wp->w_buffer != curbuf) {
apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, false, curbuf);
other_buffer = true;
@ -4500,7 +4508,7 @@ static void win_enter_ext(win_T *wp, bool undo_sync, bool curwin_invalid, bool t
}
// sync undo before leaving the current buffer
if (undo_sync && curbuf != wp->w_buffer) {
if ((flags & WEE_UNDO_SYNC) && curbuf != wp->w_buffer) {
u_sync(false);
}
@ -4561,10 +4569,10 @@ static void win_enter_ext(win_T *wp, bool undo_sync, bool curwin_invalid, bool t
shorten_fnames(true);
}
if (trigger_new_autocmds) {
if (flags & WEE_TRIGGER_NEW_AUTOCMDS) {
apply_autocmds(EVENT_WINNEW, NULL, NULL, false, curbuf);
}
if (trigger_enter_autocmds) {
if (flags & WEE_TRIGGER_ENTER_AUTOCMDS) {
apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf);
if (other_buffer) {
apply_autocmds(EVENT_BUFENTER, NULL, NULL, false, curbuf);