aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-08-21 16:44:27 +0100
committerSean Dewar <seandewar@users.noreply.github.com>2021-09-17 01:46:24 +0100
commit7ff5f02821dadb35b560650e35c90f74878a962d (patch)
treead72ada67f92053ccde2cecf7cb4a2c53b6b24b5
parentc2a65921d762929a1b8e740aeb92c7970d025736 (diff)
downloadrneovim-7ff5f02821dadb35b560650e35c90f74878a962d.tar.gz
rneovim-7ff5f02821dadb35b560650e35c90f74878a962d.tar.bz2
rneovim-7ff5f02821dadb35b560650e35c90f74878a962d.zip
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. https://github.com/vim/vim/commit/d61f2f772a59617850e9aa2f5fa069c1aad8e074 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. https://github.com/vim/vim/commit/f18e8a969a3414ed5e6b7159c40fe43963021ff3 vim-patch:8.2.3298: build failure with small features Problem: Build failure with small features. Solution: Add #ifdef. https://github.com/vim/vim/commit/6f6d58c3809010b1386634c1aeec61f1a66e72c2 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. https://github.com/vim/vim/commit/ed7cb2df35244e40e5c4df06169b50e705427576 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. https://github.com/vim/vim/commit/92755bba30ec7a4c72ae0280420ba5c3847a9385 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. https://github.com/vim/vim/commit/434df7a401c92d4084bb0a01ffd6d1737ae0193b
-rw-r--r--src/nvim/window.c54
1 files changed, 31 insertions, 23 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 75ecf90b14..b68f128875 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -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);