From 17e96d96bac4ea9074a337b263fe85d4755106b6 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 24 Sep 2019 22:53:20 -0400 Subject: vim-patch:8.1.0514: CTRL-W ^ does not work when alternate buffer has no name Problem: CTRL-W ^ does not work when alternate buffer has no name. Solution: Use another method to split and edit the alternate buffer. (Jason Franklin) https://github.com/vim/vim/commit/1bbb61948342b5cf6e363629f145c65eb455c388 --- src/nvim/window.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 1e6de73549..d7df048588 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -131,8 +131,20 @@ do_window ( case '^': CHECK_CMDWIN; reset_VIsual_and_resel(); // stop Visual mode - cmd_with_count("split #", (char_u *)cbuf, sizeof(cbuf), Prenum); - do_cmdline_cmd(cbuf); + + if (buflist_findnr(Prenum == 0 ? curwin->w_alt_fnum : Prenum) == NULL) { + if (Prenum == 0) { + EMSG(_(e_noalt)); + } else { + EMSGN(_("E92: Buffer %" PRId64 " not found"), Prenum); + } + break; + } + + if (!curbuf_locked() && win_split(0, 0) == OK) { + (void)buflist_getfile(Prenum == 0 ? curwin->w_alt_fnum : Prenum, + (linenr_T)0, GETF_ALT, false); + } break; /* open new window */ -- cgit From 6ed20ff25cd738ab2b9e79af8e3a9c37ba52dbcf Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 12 May 2019 09:08:31 -0400 Subject: vim-patch:8.1.1327: unnecessary scroll after horizontal split Problem: Unnecessary scroll after horizontal split. Solution: Don't adjust to fraction if all the text fits in the window. (Martin Kunev, closes vim/vim#4367) https://github.com/vim/vim/commit/a9b2535f44f3265940a18d08520a9ad4ef7bda82 --- src/nvim/window.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index d7df048588..1f23646bdf 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5610,10 +5610,13 @@ void scroll_to_fraction(win_T *wp, int prev_height) int sline, line_size; int height = wp->w_height_inner; - // Don't change w_topline when height is zero. Don't set w_topline when - // 'scrollbind' is set and this isn't the current window. + // Don't change w_topline in any of these cases: + // - window height is 0 + // - 'scrollbind' is set and this isn't the current window + // - window height is sufficient to display the whole buffer if (height > 0 && (!wp->w_p_scb || wp == curwin) + && (height < wp->w_buffer->b_ml.ml_line_count) ) { /* * Find a value for w_topline that shows the cursor at the same -- cgit From 90c2abc53faed9aab8ad71395068e7b09d6dea85 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 18 May 2019 18:54:25 -0400 Subject: vim-patch:8.1.1347: fractional scroll position not restored after closing window Problem: Fractional scroll position not restored after closing window. Solution: Do restore fraction if topline is not one. https://github.com/vim/vim/commit/bd2d68c2f42c7689f681aeaf82606d17f8a0312f --- src/nvim/window.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 1f23646bdf..4d8eaa9dcc 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5613,10 +5613,11 @@ void scroll_to_fraction(win_T *wp, int prev_height) // Don't change w_topline in any of these cases: // - window height is 0 // - 'scrollbind' is set and this isn't the current window - // - window height is sufficient to display the whole buffer + // - window height is sufficient to display the whole buffer and first line + // is visible. if (height > 0 && (!wp->w_p_scb || wp == curwin) - && (height < wp->w_buffer->b_ml.ml_line_count) + && (height < wp->w_buffer->b_ml.ml_line_count || wp->w_topline > 1) ) { /* * Find a value for w_topline that shows the cursor at the same -- cgit From 194f7bfacea934177d524197127242947bd28471 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 10 Oct 2019 22:06:45 +0100 Subject: vim-patch:8.1.1228: not possible to process tags with a function Problem: Not possible to process tags with a function. Solution: Add tagfunc() (Christian Brabandt, Andy Massimino, closes vim/vim#4010) https://github.com/vim/vim/commit/45e18cbdc40afd8144d20dcc07ad2d981636f4c9 --- src/nvim/window.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 4d8eaa9dcc..976f1d8ff0 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -70,8 +70,8 @@ static char *m_onlyone = N_("Already only one window"); /* * all CTRL-W window commands are handled here, called from normal_cmd(). */ -void -do_window ( +void +do_window( int nchar, long Prenum, int xchar /* extra char from ":wincmd gx" or NUL */ @@ -1537,10 +1537,14 @@ static void win_init(win_T *newp, win_T *oldp, int flags) /* copy tagstack and folds */ for (i = 0; i < oldp->w_tagstacklen; i++) { - newp->w_tagstack[i] = oldp->w_tagstack[i]; - if (newp->w_tagstack[i].tagname != NULL) - newp->w_tagstack[i].tagname = - vim_strsave(newp->w_tagstack[i].tagname); + taggy_T *tag = &newp->w_tagstack[i]; + *tag = oldp->w_tagstack[i]; + if (tag->tagname != NULL) { + tag->tagname = vim_strsave(tag->tagname); + } + if (tag->user_data != NULL) { + tag->user_data = vim_strsave(tag->user_data); + } } newp->w_tagstackidx = oldp->w_tagstackidx; newp->w_tagstacklen = oldp->w_tagstacklen; -- cgit From 3b6b528ea98ca7bf8cd5ae1cf103203e3ca67814 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 10 Oct 2019 23:40:57 +0100 Subject: vim-patch:8.1.1962: leaking memory when using tagfunc() Problem: Leaking memory when using tagfunc(). Solution: Free the user_data. (Dominique Pelle, closes vim/vim#4886) https://github.com/vim/vim/commit/55008aad50601cae079037fda8fb434cde70c0f4 --- src/nvim/window.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 976f1d8ff0..ce5be8e904 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -4642,8 +4642,10 @@ win_free ( xfree(wp->w_lines); - for (i = 0; i < wp->w_tagstacklen; ++i) + for (i = 0; i < wp->w_tagstacklen; i++) { xfree(wp->w_tagstack[i].tagname); + xfree(wp->w_tagstack[i].user_data); + } xfree(wp->w_localdir); -- cgit From 8257d49ff6bd825e8f4ffca189cd6c23bd0c66be Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 14 Oct 2019 01:30:53 -0400 Subject: vim-patch:8.1.0410: the ex_copen() function is too long Problem: The ex_copen() function is too long. Solution: Refactor to split off two functions. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/476c0db00205590974395df717519407a7717270 --- src/nvim/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index ce5be8e904..d4a0db9c89 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1574,7 +1574,7 @@ static void win_init_some(win_T *newp, win_T *oldp) /// Check if "win" is a pointer to an existing window in the current tabpage. /// /// @param win window to check -bool win_valid(win_T *win) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT +bool win_valid(const win_T *win) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { if (win == NULL) { return false; -- cgit From 279ff233799f23dc8a11882fe78df79f9dafdfa3 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 14 Oct 2019 10:00:14 -0400 Subject: vim-patch:8.1.0434: copy_loclist() is too long Problem: copy_loclist() is too long. Solution: Split in multiple functions. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/09037503ea5f957ad23121bc61e15e4bb1765edf --- src/nvim/window.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index d4a0db9c89..0531ad1938 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1530,8 +1530,9 @@ static void win_init(win_T *newp, win_T *oldp, int flags) /* Don't copy the location list. */ newp->w_llist = NULL; newp->w_llist_ref = NULL; - } else - copy_loclist(oldp, newp); + } else { + copy_loclist_stack(oldp, newp); + } newp->w_localdir = (oldp->w_localdir == NULL) ? NULL : vim_strsave(oldp->w_localdir); -- cgit From b83027858af71e5ca976c3b43e0b798c624f5529 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 16 Nov 2019 16:13:51 -0500 Subject: vim-patch:8.1.2289: after :diffsplit closing the window does not disable diff Problem: After :diffsplit closing the window does not disable diff. Solution: Add "closeoff" to 'diffopt' and add it to the default. https://github.com/vim/vim/commit/c8234779790dd873acb88331c50988adf94cc383 --- src/nvim/window.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 0531ad1938..2a7578e33c 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2418,6 +2418,7 @@ int win_close(win_T *win, bool free_buf) bool help_window = false; tabpage_T *prev_curtab = curtab; frame_T *win_frame = win->w_floating ? NULL : win->w_frame->fr_parent; + const bool had_diffmode = win->w_p_diff; if (last_window() && !win->w_floating) { EMSG(_("E444: Cannot close last window")); @@ -2642,6 +2643,22 @@ int win_close(win_T *win, bool free_buf) if (help_window) restore_snapshot(SNAP_HELP_IDX, close_curwin); + // If the window had 'diff' set and now there is only one window left in + // the tab page with 'diff' set, and "closeoff" is in 'diffopt', then + // execute ":diffoff!". + if (diffopt_closeoff() && had_diffmode && curtab == prev_curtab) { + int diffcount = 0; + + FOR_ALL_WINDOWS_IN_TAB(dwin, curtab) { + if (dwin->w_p_diff) { + diffcount++; + } + } + if (diffcount == 1) { + do_cmdline_cmd("diffoff!"); + } + } + curwin->w_pos_changed = true; redraw_all_later(NOT_VALID); return OK; -- cgit From d5f14b8372b3c8d441187eea659156534cb4c9ba Mon Sep 17 00:00:00 2001 From: Dennis B Date: Fri, 22 Nov 2019 20:55:04 +1100 Subject: Clear 'cc' in nvim_open_win 'minimal' style #11361 (#11427) * Clear 'cc' in nvim_open_win 'minimal' style #11361 Add 'colorcolumn' to the list of options that should be cleared when creating a 'minimal'-style floating window. --- src/nvim/window.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 2a7578e33c..dee36df433 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -633,6 +633,12 @@ void win_set_minimal_style(win_T *wp) xfree(wp->w_p_scl); wp->w_p_scl = (char_u *)xstrdup("auto"); } + + // colorcolumn: cleared + if (wp->w_p_cc != NULL && *wp->w_p_cc != NUL) { + xfree(wp->w_p_cc); + wp->w_p_cc = (char_u *)xstrdup(""); + } } void win_config_float(win_T *wp, FloatConfig fconfig) -- cgit From f6e7857c54a015cdfac9ce65ec0b65d65d590aeb Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 29 Nov 2019 23:48:14 -0800 Subject: floatwin: show error if window is closed immediately #11476 Autocmds may close window while it is being entered, then win_set_minimal_style(wp) operates on an invalid pointer. We could silently ignore this instead, but it is unlikely to be intentional, so it is more useful to show an error. fix #11383 --- src/nvim/window.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index dee36df433..76fc36607c 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -4372,9 +4372,10 @@ static void win_goto_hor(bool left, long count) } } -/* - * Make window "wp" the current window. - */ +/// Make window `wp` the current window. +/// +/// @warning Autocmds may close the window immediately, so caller must check +/// win_valid(wp). void win_enter(win_T *wp, bool undo_sync) { win_enter_ext(wp, undo_sync, false, false, true, true); -- cgit From 80ebfc304e295cdb1bed3d0f2781d7884933719a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 22 Dec 2019 18:45:17 -0500 Subject: vim-patch:8.2.0030: "gF" does not work on output of "verbose command" Problem: "gF" does not work on output of "verbose command". Solution: Recognize " line " and translations. (closes vim/vim#5391) https://github.com/vim/vim/commit/64e74c9cc7d5aab215cf72d9bdd3aac32e128191 --- src/nvim/window.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 76fc36607c..af78c89618 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -6020,10 +6020,20 @@ file_name_in_line ( if (file_lnum != NULL) { char_u *p; + const char *line_english = " line "; + const char *line_transl = _(line_msg); // Get the number after the file name and a separator character. + // Also accept " line 999" with and without the same translation as + // used in last_set_msg(). p = ptr + len; - p = skipwhite(p); + if (STRNCMP(p, line_english, STRLEN(line_english)) == 0) { + p += STRLEN(line_english); + } else if (STRNCMP(p, line_transl, STRLEN(line_transl)) == 0) { + p += STRLEN(line_transl); + } else { + p = skipwhite(p); + } if (*p != NUL) { if (!isdigit(*p)) { p++; // skip the separator -- cgit From 6e6544d645f9a9c151a2e027e23d8f79ecd8f7c9 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 30 Dec 2019 16:24:21 -0500 Subject: vim-patch:8.1.1739: deleted match highlighting not updated in other window Problem: Deleted match highlighting not updated in other window. Solution: Mark the window for refresh. (closes vim/vim#4720) Also fix that ambi-width check clears with wrong attributes. https://github.com/vim/vim/commit/06029a857a3d4d90b3162090506c1e00dc84c60b --- src/nvim/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index af78c89618..5d4332c75a 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -6680,7 +6680,7 @@ int match_delete(win_T *wp, int id, int perr) rtype = VALID; } xfree(cur); - redraw_later(rtype); + redraw_win_later(wp, rtype); return 0; } -- cgit From 0e7baed2195fec8e99df69112e464791c02b2555 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 30 Dec 2019 16:27:26 -0500 Subject: vim-patch:8.1.1741: cleared/added match highlighting not updated in other window Problem: Cleared/added match highlighting not updated in other window. (Andi Massimino) Solution: Mark the right window for refresh. https://github.com/vim/vim/commit/4ef18dcc2e3a6a9aea2dc90bbdb742c3c9231394 --- src/nvim/window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 5d4332c75a..79d7a8acba 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -6622,7 +6622,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, prev->next = m; m->next = cur; - redraw_later(rtype); + redraw_win_later(wp, rtype); return id; fail: @@ -6698,7 +6698,7 @@ void clear_matches(win_T *wp) xfree(wp->w_match_head); wp->w_match_head = m; } - redraw_later(SOME_VALID); + redraw_win_later(wp, SOME_VALID); } /* -- cgit From cbc8d72fde4b19176028490934ff7a447afe523c Mon Sep 17 00:00:00 2001 From: butwerenotthereyet <58348703+butwerenotthereyet@users.noreply.github.com> Date: Thu, 2 Jan 2020 06:06:11 -0800 Subject: tabpage: track last-used tabpage #11626 In a multi-window scenario, it is possible to return focus to the last accessed window via n_CTRL-W_p. However, in the case of a multi-tab scenario, there was previously no way to return focus to the last accessed *tab*. Here, that ability is added via n_g. Additionally, the index of the previous tab is exposed via tabpagenr('#'), mirroring the existing functionality of winnr('#'). --- src/nvim/window.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 79d7a8acba..4d105dd11e 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -519,6 +519,10 @@ wingotofile: do_nv_ident('g', xchar); break; + case TAB: + goto_tabpage_lastused(); + break; + case 'f': /* CTRL-W gf: "gf" in a new tab page */ case 'F': /* CTRL-W gF: "gF" in a new tab page */ cmdmod.tab = tabpage_index(curtab) + 1; @@ -3691,6 +3695,10 @@ void free_tabpage(tabpage_T *tp) hash_init(&tp->tp_vars->dv_hashtab); unref_var_dict(tp->tp_vars); + if (tp == lastused_tabpage) { + lastused_tabpage = NULL; + } + xfree(tp->tp_localdir); xfree(tp); } @@ -3750,6 +3758,8 @@ int win_new_tabpage(int after, char_u *filename) tabpage_check_windows(tp); + lastused_tabpage = tp; + apply_autocmds(EVENT_WINNEW, NULL, NULL, false, curbuf); apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf); apply_autocmds(EVENT_TABNEW, filename, filename, false, curbuf); @@ -3976,6 +3986,7 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_au if (curtab->tp_old_Columns != Columns && starting == 0) shell_new_columns(); /* update window widths */ + lastused_tabpage = old_curtab; /* Apply autocommands after updating the display, when 'rows' and * 'columns' have been set correctly. */ @@ -4095,6 +4106,14 @@ void goto_tabpage_tp(tabpage_T *tp, int trigger_enter_autocmds, int trigger_leav } } +// Go to the last accessed tab page, if there is one. +void goto_tabpage_lastused(void) +{ + if (valid_tabpage(lastused_tabpage)) { + goto_tabpage_tp(lastused_tabpage, true, true); + } +} + /* * Enter window "wp" in tab page "tp". * Also updates the GUI tab. -- cgit From 42aa8764881ed8572d563766575c053db085f6db Mon Sep 17 00:00:00 2001 From: We're Yet <58348703+butwerenotthereyet@users.noreply.github.com> Date: Wed, 1 Jan 2020 09:52:13 -0800 Subject: vim-patch:8.1.0972: cannot switch from terminal window to next tabpage Problem: Cannot switch from terminal window to next tabpage. Solution: Make CTRL-W gt move to next tabpage. https://github.com/vim/vim/commit/72e83c1ae535e2ebc35b114d34d0a811eb62b068 --- src/nvim/window.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 4d105dd11e..d62510b951 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -528,6 +528,9 @@ wingotofile: cmdmod.tab = tabpage_index(curtab) + 1; nchar = xchar; goto wingotofile; + case 't': // CTRL-W gt: go to next tab page + goto_tabpage((int)Prenum); + break; case 'e': if (curwin->w_floating || !ui_has(kUIMultigrid)) { -- cgit From a7b6b375196ad2d0531550b2e1c7888502c9512b Mon Sep 17 00:00:00 2001 From: We're Yet <58348703+butwerenotthereyet@users.noreply.github.com> Date: Wed, 1 Jan 2020 10:08:06 -0800 Subject: vim-patch:8.1.0974: cannot switch from terminal window to previous tabpage Problem: Cannot switch from terminal window to previous tabpage. Solution: Make CTRL-W gT move to previous tabpage. https://github.com/vim/vim/commit/882d02eeb571a13a502fe82a04c9eaffa630c294 --- src/nvim/window.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index d62510b951..8feedf2de6 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -85,10 +85,7 @@ do_window( size_t len; char cbuf[40]; - if (Prenum == 0) - Prenum1 = 1; - else - Prenum1 = Prenum; + Prenum1 = Prenum == 0 ? 1 : Prenum; # define CHECK_CMDWIN \ do { \ @@ -532,6 +529,10 @@ wingotofile: goto_tabpage((int)Prenum); break; + case 'T': // CTRL-W gT: go to previous tab page + goto_tabpage(-(int)Prenum1); + break; + case 'e': if (curwin->w_floating || !ui_has(kUIMultigrid)) { beep_flush(); -- cgit From 29b1a4761a9fadfa9de05cfd9c8aad281fc29791 Mon Sep 17 00:00:00 2001 From: butwerenotthereyet <58348703+butwerenotthereyet@users.noreply.github.com> Date: Thu, 9 Jan 2020 07:31:16 -0800 Subject: tabpage: disallow go-to-previous in cmdline-win #11692 After cbc8d72fde4b19176028490934ff7a447afe523c when editing the command in the command editing window (q:, q/, q?) it was possible to switch to the previous tab. Doing so put Nvim in a bad state. Moreover, switching tabs via the other available mechanisms (gt, gT, gt, gT) is not possible when in the command editing window. Here, the behavior is prevented. It is no longer possible to switch to the previous tab when editing the command in the command editing window. The solution is to share code between gt, gT, and g. Specifically, goto_tabpage_lastused now calls through goto_tabpage rather than directly calling goto_tabpage_tp. Doing so works well because all the validation enjoyed by gt and gT is present in goto_tabpage. --- src/nvim/window.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 8feedf2de6..e913d33de0 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -4113,8 +4113,9 @@ void goto_tabpage_tp(tabpage_T *tp, int trigger_enter_autocmds, int trigger_leav // Go to the last accessed tab page, if there is one. void goto_tabpage_lastused(void) { - if (valid_tabpage(lastused_tabpage)) { - goto_tabpage_tp(lastused_tabpage, true, true); + int index = tabpage_index(lastused_tabpage); + if (index < tabpage_index(NULL)) { + goto_tabpage(index); } } -- cgit From 757aad92e84709a08320a06870b6acb086bc6876 Mon Sep 17 00:00:00 2001 From: Marcos ALMEIDA Date: Sat, 29 Sep 2018 20:40:53 +0200 Subject: autocmd: add WinClosed event - only fire once, just before freeing mem - trigger when on a different buffer - avoid recursive calls in another tab --- src/nvim/window.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index e913d33de0..4743dca3ff 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2502,9 +2502,10 @@ int win_close(win_T *win, bool free_buf) return FAIL; } win->w_closing = true; - apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); - if (!win_valid(win)) + apply_autocmds(EVENT_WINLEAVE, NULL, NULL, false, curbuf); + if (!win_valid(win)) { return FAIL; + } win->w_closing = false; if (last_window()) return FAIL; @@ -2534,6 +2535,12 @@ int win_close(win_T *win, bool free_buf) } } + // Fire WinClosed just before starting to free window-related resources. + do_autocmd_winclosed(win); + // autocmd may have freed the window already. + if (!win_valid_any_tab(win)) { + return OK; + } /* Free independent synblock before the buffer is freed. */ if (win->w_buffer != NULL) @@ -2576,6 +2583,7 @@ int win_close(win_T *win, bool free_buf) win_close_othertab(win, false, prev_curtab); return FAIL; } + // Autocommands may have closed the window already, or closed the only // other window or moved to another tab page. if (!win_valid(win) || (!win->w_floating && last_window()) @@ -2585,8 +2593,9 @@ int win_close(win_T *win, bool free_buf) // let terminal buffers know that this window dimensions may be ignored win->w_closing = true; - /* Free the memory used for the window and get the window that received - * the screen space. */ + + // Free the memory used for the window and get the window that received + // the screen space. wp = win_free_mem(win, &dir, NULL); if (help_window) { @@ -2678,6 +2687,19 @@ int win_close(win_T *win, bool free_buf) return OK; } +static void do_autocmd_winclosed(win_T *win) + FUNC_ATTR_NONNULL_ALL +{ + static bool recursive = false; + if (recursive || !has_event(EVENT_WINCLOSED)) { + return; + } + recursive = true; + apply_autocmds(EVENT_WINCLOSED, win->w_buffer->b_fname, + win->w_buffer->b_fname, false, win->w_buffer); + recursive = false; +} + /* * Close window "win" in tab page "tp", which is not the current tab page. * This may be the last window in that tab page and result in closing the tab, @@ -2698,6 +2720,13 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) return; // window is already being closed } + // Fire WinClosed just before starting to free window-related resources. + do_autocmd_winclosed(win); + // autocmd may have freed the window already. + if (!win_valid_any_tab(win)) { + return; + } + if (win->w_buffer != NULL) { // Close the link to the buffer. close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, false); -- cgit From 2b8e66c6ce0a5ccae09023732c06da90f96ed5f5 Mon Sep 17 00:00:00 2001 From: notomo Date: Tue, 14 Jan 2020 22:34:05 +0900 Subject: autocmd: WinClosed exposes window id as --- src/nvim/window.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 4743dca3ff..9efed49e70 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2695,8 +2695,10 @@ static void do_autocmd_winclosed(win_T *win) return; } recursive = true; - apply_autocmds(EVENT_WINCLOSED, win->w_buffer->b_fname, - win->w_buffer->b_fname, false, win->w_buffer); + + char_u winid[10]; + vim_snprintf((char *)winid, sizeof(winid), "%i", win->handle); + apply_autocmds(EVENT_WINCLOSED, winid, winid, false, win->w_buffer); recursive = false; } -- cgit From 156c25e4983d4c106ba70e5e3bcc6bbb012d8065 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 13 Jan 2020 00:19:20 -0800 Subject: WinClosed: sort auevents.lua; improve tests - test: reduce verbosity, condense redundancy, improve readability - auevents.lua: keep events sorted by name. ref afd1d412fa91 --- src/nvim/window.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 9efed49e70..8181883426 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2695,8 +2695,7 @@ static void do_autocmd_winclosed(win_T *win) return; } recursive = true; - - char_u winid[10]; + char_u winid[NUMBUFLEN]; vim_snprintf((char *)winid, sizeof(winid), "%i", win->handle); apply_autocmds(EVENT_WINCLOSED, winid, winid, false, win->w_buffer); recursive = false; -- cgit From 1a2be57da3f7e33af4e4eb3e0d36569feea71253 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 14 Jan 2020 19:50:30 +0100 Subject: foldcolumn: allow auto:X Similar to signcolumn, allow foldcolumn to adapt itself to the number of folds. Regression: vim supports a maximum fdc of 12, this limits it to 9. --- src/nvim/window.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 8181883426..df0033a203 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -618,7 +618,6 @@ void win_set_minimal_style(win_T *wp) wp->w_p_cuc = false; wp->w_p_spell = false; wp->w_p_list = false; - wp->w_p_fdc = 0; // Hide EOB region: use " " fillchar and cleared highlighting if (wp->w_p_fcs_chars.eob != ' ') { @@ -642,6 +641,12 @@ void win_set_minimal_style(win_T *wp) wp->w_p_scl = (char_u *)xstrdup("auto"); } + // foldcolumn: use 'auto' + if (wp->w_p_fdc[0] != '0') { + xfree(wp->w_p_fdc); + wp->w_p_fdc = (char_u *)xstrdup("0"); + } + // colorcolumn: cleared if (wp->w_p_cc != NULL && *wp->w_p_cc != NUL) { xfree(wp->w_p_cc); @@ -689,6 +694,24 @@ void win_check_anchored_floats(win_T *win) } } +/// Return the number of requested fold columns, based on current +/// folds signs and on user configuration. +int win_fdccol_count(win_T *wp) +{ + const char *fdc = (const char *)wp->w_p_fdc; + + // auto: + if (strncmp(fdc, "auto:", 5) == 0) { + int needed_fdccols; + needed_fdccols = getDeepestNesting(wp); + int maximum = fdc[5] - '0'; + return MIN(maximum, needed_fdccols); + } else { + return fdc[0] - '0'; + } +} + + static void ui_ext_win_position(win_T *wp) { if (!wp->w_floating) { -- cgit From 4ffae76520c924fa9f3d5f9850f84c89c002877c Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sun, 1 Mar 2020 16:43:06 +0100 Subject: addressing reviews --- src/nvim/window.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index df0033a203..f61a46996d 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -694,18 +694,15 @@ void win_check_anchored_floats(win_T *win) } } -/// Return the number of requested fold columns, based on current -/// folds signs and on user configuration. +/// Return the number of fold columns to display int win_fdccol_count(win_T *wp) { const char *fdc = (const char *)wp->w_p_fdc; // auto: if (strncmp(fdc, "auto:", 5) == 0) { - int needed_fdccols; - needed_fdccols = getDeepestNesting(wp); - int maximum = fdc[5] - '0'; - return MIN(maximum, needed_fdccols); + int needed_fdccols = getDeepestNesting(wp); + return MIN(fdc[5] - '0', needed_fdccols); } else { return fdc[0] - '0'; } -- cgit From 87d892afa0475644e91d9c8a57b7c35491c4dc32 Mon Sep 17 00:00:00 2001 From: Will Eccles Date: Tue, 17 Mar 2020 15:05:34 -0400 Subject: vim-patch:8.1.0864 Make 'scrolloff' and 'sidescrolloff' options window local (#11854) Problem: cannot have a local value for 'scrolloff' and 'sidescrolloff' Author: Bram Moolenar https://github.com/vim/vim/commit/375e3390078e740d3c83b0c118c50d9a920036c7 --- src/nvim/window.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index f61a46996d..fb3f1e0c9f 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -4689,6 +4689,10 @@ static win_T *win_alloc(win_T *after, int hidden) new_wp->w_floating = 0; new_wp->w_float_config = FLOAT_CONFIG_INIT; + // use global option for global-local options + new_wp->w_p_so = -1; + new_wp->w_p_siso = -1; + /* We won't calculate w_fraction until resizing the window */ new_wp->w_fraction = 0; new_wp->w_prev_fraction_row = -1; @@ -5799,9 +5803,10 @@ void scroll_to_fraction(win_T *wp, int prev_height) } if (wp == curwin) { - if (p_so) + if (get_scrolloff_value()) { update_topline(); - curs_columns(FALSE); /* validate w_wrow */ + } + curs_columns(false); // validate w_wrow } if (prev_height > 0) { wp->w_prev_fraction_row = wp->w_wrow; -- cgit From 1fe0b329fe1d40e5837a43f53da0e0fff38477bc Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Thu, 23 Jan 2020 18:05:04 +0100 Subject: api/ui: win_viewport event for visible range and cursor position in window --- src/nvim/window.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index fb3f1e0c9f..9ec47f8e89 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -773,6 +773,21 @@ static void ui_ext_win_position(win_T *wp) } +void ui_ext_win_viewport(win_T *wp) +{ + if ((wp == curwin || ui_has(kUIMultigrid)) && wp->w_viewport_invalid) { + int botline = wp->w_botline; + if (botline == wp->w_buffer->b_ml.ml_line_count+1 + && wp->w_empty_rows == 0) { + // TODO(bfredl): The might be more cases to consider, like how does this + // interact with incomplete final line? Diff filler lines? + botline = wp->w_buffer->b_ml.ml_line_count; + } + ui_call_win_viewport(wp->w_grid.handle, wp->handle, wp->w_topline-1, + botline, wp->w_cursor.lnum-1, wp->w_cursor.col); + wp->w_viewport_invalid = false; + } +} static bool parse_float_anchor(String anchor, FloatAnchor *out) { @@ -4688,6 +4703,7 @@ static win_T *win_alloc(win_T *after, int hidden) new_wp->w_scbind_pos = 1; new_wp->w_floating = 0; new_wp->w_float_config = FLOAT_CONFIG_INIT; + new_wp->w_viewport_invalid = true; // use global option for global-local options new_wp->w_p_so = -1; @@ -6992,7 +7008,7 @@ void get_framelayout(const frame_T *fr, list_T *l, bool outer) } } -void win_ui_flush_positions(void) +void win_ui_flush(void) { FOR_ALL_TAB_WINDOWS(tp, wp) { if (wp->w_pos_changed && wp->w_grid.chars != NULL) { @@ -7003,6 +7019,9 @@ void win_ui_flush_positions(void) } wp->w_pos_changed = false; } + if (tp == curtab) { + ui_ext_win_viewport(wp); + } } } -- cgit From 22eb3c9e4933d440f3ad8f55e37e7370a69c765e Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 21 Mar 2020 11:04:09 -0400 Subject: vim-patch:8.1.1745: compiler warning for unused argument Problem: Compiler warning for unused argument. Solution: Add UNUSED. Change comments to new style. https://github.com/vim/vim/commit/1f164b19685d8ad709b11f3f1933685469251e30 --- src/nvim/window.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 9ec47f8e89..a89715ff79 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -6544,10 +6544,12 @@ void restore_buffer(bufref_T *save_curbuf) /// @param[in] id a desired ID 'id' can be specified /// (greater than or equal to 1). -1 must be specified if no /// particular ID is desired +/// @param[in] conceal_char pointer to conceal replacement char /// @return ID of added match, -1 on failure. int match_add(win_T *wp, const char *const grp, const char *const pat, int prio, int id, list_T *pos_list, const char *const conceal_char) + FUNC_ATTR_NONNULL_ARG(1, 2) { matchitem_T *cur; matchitem_T *prev; @@ -6584,7 +6586,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, return -1; } - /* Find available match ID. */ + // Find available match ID. while (id == -1) { cur = wp->w_match_head; while (cur != NULL && cur->id != wp->w_next_match_id) @@ -6594,7 +6596,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, wp->w_next_match_id++; } - /* Build new match. */ + // Build new match. m = xcalloc(1, sizeof(matchitem_T)); m->id = id; m->priority = prio; @@ -6702,9 +6704,9 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, rtype = VALID; } } - - /* Insert new match. The match list is in ascending order with regard to - * the match priorities. */ + + // Insert new match. The match list is in ascending order with regard to + // the match priorities. cur = wp->w_match_head; prev = cur; while (cur != NULL && prio >= cur->priority) { -- cgit From 64b61d49c2c3350833ca490c9fdf8540298cd01a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 13 Mar 2020 22:05:05 -0400 Subject: vim-patch:8.0.1123: cannot define a toolbar for a window Problem: Cannot define a toolbar for a window. Solution: Add a window-local toolbar. https://github.com/vim/vim/commit/1b9645de3c05f37b5c30e78f999351b0cf486ade "WinBar" code in "screen.c" was not ported. Fix https://github.com/neovim/neovim/issues/11513#issuecomment-562012827 --- src/nvim/window.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index a89715ff79..23836f3895 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -4782,6 +4782,7 @@ win_free ( qf_free_all(wp); + remove_winbar(wp); xfree(wp->w_p_cc_cols); @@ -5708,11 +5709,10 @@ void set_fraction(win_T *wp) } } -/* - * Set the height of a window. - * This takes care of the things inside the window, not what happens to the - * window position, the frame or to other windows. - */ +// Set the height of a window. +// "height" excludes any window toolbar. +// This takes care of the things inside the window, not what happens to the +// window position, the frame or to other windows. void win_new_height(win_T *wp, int height) { // Don't want a negative height. Happens when splitting a tiny window. -- cgit From 9758f5e5087a046fe8b624a3e64bdae020bbfe99 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 14 Mar 2020 07:08:03 -0400 Subject: vim-patch:8.0.1125: wrong window height when splitting window with window toolbar Problem: Wrong window height when splitting window with window toolbar. Solution: Add or subtract the window toolbar height. https://github.com/vim/vim/commit/d326ad6e93604222c64bae51f47521fe9114d1ea --- src/nvim/window.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 23836f3895..13d1dbbce9 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1407,12 +1407,12 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) if (flags & (WSP_TOP | WSP_BOT)) { /* set height and row of new window to full height */ wp->w_winrow = tabline_height(); - win_new_height(wp, curfrp->fr_height - (p_ls > 0)); + win_new_height(wp, curfrp->fr_height - (p_ls > 0) - wp->w_winbar_height); wp->w_status_height = (p_ls > 0); } else { /* height and row of new window is same as current window */ wp->w_winrow = oldwin->w_winrow; - win_new_height(wp, oldwin->w_height); + win_new_height(wp, oldwin->w_height + oldwin->w_winbar_height); wp->w_status_height = oldwin->w_status_height; } frp->fr_height = curfrp->fr_height; @@ -1459,7 +1459,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) * one row for the status line */ win_new_height(wp, new_size); if (flags & (WSP_TOP | WSP_BOT)) { - int new_fr_height = curfrp->fr_height - new_size; + int new_fr_height = curfrp->fr_height - new_size + wp->w_winbar_height; if (!((flags & WSP_BOT) && p_ls == 0)) { new_fr_height -= STATUS_HEIGHT; @@ -3144,15 +3144,18 @@ frame_new_height ( int wfh /* obey 'winfixheight' when there is a choice; may cause the height not to be set */ ) + FUNC_ATTR_NONNULL_ALL { frame_T *frp; int extra_lines; int h; if (topfrp->fr_win != NULL) { - /* Simple case: just one window. */ + // Simple case: just one window. win_new_height(topfrp->fr_win, - height - topfrp->fr_win->w_status_height); + height + - topfrp->fr_win->w_status_height + - topfrp->fr_win->w_winbar_height); } else if (topfrp->fr_layout == FR_ROW) { do { // All frames in this row get the same new height. @@ -3457,8 +3460,10 @@ static void frame_fix_width(win_T *wp) * Set frame height from the window it contains. */ static void frame_fix_height(win_T *wp) + FUNC_ATTR_NONNULL_ALL { - wp->w_frame->fr_height = wp->w_height + wp->w_status_height; + wp->w_frame->fr_height = + wp->w_height + wp->w_status_height + wp->w_winbar_height; } /* -- cgit From 86d0f67c292ed51a981b643cf80a851f92c2b4da Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 14 Mar 2020 11:38:43 -0400 Subject: vim-patch:8.0.1334: splitting a window with a WinBar damages window layout Problem: Splitting a window with a WinBar damages window layout. (Lifepillar) Solution: Take the winbar into account when computing the new window position. Add WINBAR_HEIGHT(). https://github.com/vim/vim/commit/3167c3e7010ac7e2fd7d3aa198dd2d1dcff8ecc8 --- src/nvim/window.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 13d1dbbce9..fe6f829a5f 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1472,8 +1472,9 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) wp->w_winrow = oldwin->w_winrow; wp->w_status_height = STATUS_HEIGHT; oldwin->w_winrow += wp->w_height + STATUS_HEIGHT; - } else { /* new window below current one */ - wp->w_winrow = oldwin->w_winrow + oldwin->w_height + STATUS_HEIGHT; + } else { // new window below current one + wp->w_winrow = oldwin->w_winrow + oldwin->w_height + + STATUS_HEIGHT + oldwin->w_winbar_height; wp->w_status_height = oldwin->w_status_height; if (!(flags & WSP_BOT)) { oldwin->w_status_height = STATUS_HEIGHT; -- cgit From fcd9ce39012c9328b999c4ccb7eaa7c22766168e Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 26 Apr 2020 20:43:10 -0400 Subject: vim-patch:8.0.1375: window size wrong after maximizing with WinBar Problem: Window size wrong after maximizing with WinBar. (Lifepillar) Solution: Fix height computations. Redraw window when it is zero height but has a WinBar. (closes vim/vim#2356) https://github.com/vim/vim/commit/415a6939a4e8d4e26b4af26c24eb75243d3a2756 --- src/nvim/window.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index fe6f829a5f..0fff93d984 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1112,7 +1112,8 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) // add a status line when p_ls == 1 and splitting the first window if (one_nonfloat() && p_ls == 1 && oldwin->w_status_height == 0) { - if (oldwin->w_height <= p_wmh && new_in_layout) { + if ((oldwin->w_height + oldwin->w_winbar_height) <= p_wmh + && new_in_layout) { EMSG(_(e_noroom)); return FAIL; } @@ -1209,7 +1210,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) * height. */ // Current window requires at least 1 space. - wmh1 = (p_wmh == 0 ? 1 : p_wmh); + wmh1 = (p_wmh == 0 ? 1 : p_wmh) + curwin->w_winbar_height; needed = wmh1 + STATUS_HEIGHT; if (flags & WSP_ROOM) { needed += p_wh - wmh1; @@ -1690,8 +1691,9 @@ make_windows ( maxcount = (curwin->w_width + curwin->w_vsep_width - (p_wiw - p_wmw)) / (p_wmw + 1); } else { - /* Each window needs at least 'winminheight' lines and a status line. */ - maxcount = (curwin->w_height + curwin->w_status_height + // Each window needs at least 'winminheight' lines and a status line. + maxcount = (curwin->w_height + curwin->w_winbar_height + + curwin->w_status_height - (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT); } @@ -3481,14 +3483,18 @@ static int frame_minheight(frame_T *topfrp, win_T *next_curwin) int n; if (topfrp->fr_win != NULL) { - if (topfrp->fr_win == next_curwin) + if (topfrp->fr_win == next_curwin) { m = p_wh + topfrp->fr_win->w_status_height; - else { - /* window: minimal height of the window plus status line */ + } else { + // window: minimal height of the window plus status line m = p_wmh + topfrp->fr_win->w_status_height; - /* Current window is minimal one line high */ - if (p_wmh == 0 && topfrp->fr_win == curwin && next_curwin == NULL) - ++m; + if (topfrp->fr_win == curwin && next_curwin == NULL) { + // Current window is minimal one line high and WinBar is visible. + if (p_wmh == 0) { + m++; + } + m += curwin->w_winbar_height; + } } } else if (topfrp->fr_layout == FR_ROW) { /* get the minimal height from each frame in this row */ @@ -5055,7 +5061,9 @@ static void frame_comp_pos(frame_T *topfrp, int *row, int *col) wp->w_redr_status = true; wp->w_pos_changed = true; } - *row += wp->w_height + wp->w_status_height; + // WinBar will not show if the window height is zero + const int h = wp->w_height + wp->w_winbar_height + wp->w_status_height; + *row += h > topfrp->fr_height ? topfrp->fr_height : h; *col += wp->w_width + wp->w_vsep_width; } else { startrow = *row; @@ -5088,12 +5096,15 @@ void win_setheight(int height) void win_setheight_win(int height, win_T *win) { if (win == curwin) { - /* Always keep current window at least one line high, even when - * 'winminheight' is zero. */ - if (height < p_wmh) + // Always keep current window at least one line high, even when + // 'winminheight' is zero. + if (height < p_wmh) { height = p_wmh; - if (height == 0) + } + if (height == 0) { height = 1; + } + height += curwin->w_winbar_height; } if (win->w_floating) { @@ -5190,7 +5201,7 @@ static void frame_setheight(frame_T *curfrp, int height) } else { win_T *wp = lastwin_nofloating(); room_cmdline = Rows - p_ch - (wp->w_winrow - + wp->w_height + + + wp->w_height + wp->w_winbar_height + wp->w_status_height); if (room_cmdline < 0) { room_cmdline = 0; -- cgit