From 7ff5f02821dadb35b560650e35c90f74878a962d Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 21 Aug 2021 16:44:27 +0100 Subject: 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 --- src/nvim/window.c | 54 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) (limited to 'src/nvim/window.c') 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); -- cgit From e9ddff9d8a86e5e66ebbf7a37c5ae273c9471ccd Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 13 Aug 2021 21:01:00 +0100 Subject: vim-patch:8.2.3313: unused code in win_exchange() and frame_remove() Problem: Unused code in win_exchange() and frame_remove(). Solution: Remove the code. (closes vim/vim#8728) https://github.com/vim/vim/commit/9e2fa4bb9eb40a78a1ae1f67a4064651b5ce0aac --- src/nvim/window.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index b68f128875..4bbdaefd1f 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1719,21 +1719,10 @@ static void win_exchange(long Prenum) curwin->w_vsep_width = wp->w_vsep_width; wp->w_vsep_width = temp; - /* If the windows are not in the same frame, exchange the sizes to avoid - * messing up the window layout. Otherwise fix the frame sizes. */ - if (curwin->w_frame->fr_parent != wp->w_frame->fr_parent) { - temp = curwin->w_height; - curwin->w_height = wp->w_height; - wp->w_height = temp; - temp = curwin->w_width; - curwin->w_width = wp->w_width; - wp->w_width = temp; - } else { - frame_fix_height(curwin); - frame_fix_height(wp); - frame_fix_width(curwin); - frame_fix_width(wp); - } + frame_fix_height(curwin); + frame_fix_height(wp); + frame_fix_width(curwin); + frame_fix_width(wp); (void)win_comp_pos(); // recompute window positions @@ -4934,10 +4923,6 @@ static void frame_remove(frame_T *frp) frp->fr_prev->fr_next = frp->fr_next; } else { frp->fr_parent->fr_child = frp->fr_next; - // special case: topframe->fr_child == frp - if (topframe->fr_child == frp) { - topframe->fr_child = frp->fr_next; - } } if (frp->fr_next != NULL) { frp->fr_next->fr_prev = frp->fr_prev; -- cgit