From 6b4970f6e0ac36021b2a8bd0533f5078040d31f7 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 23 Jul 2023 19:50:20 +0100 Subject: [PATCH 1/4] feat(api): allow open_win/win_set_buf in the cmdwin in some cases Problem: As discussed on Matrix, there was some interest in having `nvim_open_win` again be able to open floats in the cmdwin (e.g: displaying a hover doc related to what's in the cmdwin). After #23228, this was disallowed. Solution: Allow `nvim_open_win` in the cmdwin as long as `!enter` and `buffer != curbuf` (the former can cause all sorts of issues, and the latter can crash Nvim after closing cmdwin). Also allow `nvim_win_set_buf` in a similar fashion. Note that we're not *entirely* sure if this is 100% safe (cmdwin is a global-state-using-main-loop-calling beast), but this seems to work OK..? Also: - Check the buffer argument of `nvim_open_win` earlier, and abort if it's invalid (it used to still open a window in this case). - Untranslate `e_cmdwin` errors in the API (other errors in the API are not translated: although not detailed in the API contract yet, errors are supposed to be stable). --- runtime/doc/api.txt | 4 +-- src/nvim/api/vim.c | 2 +- src/nvim/api/win_config.c | 13 +++++++-- src/nvim/api/window.c | 15 ++++++++--- src/nvim/window.c | 14 +++------- test/functional/api/window_spec.lua | 41 +++++++++++++++++++++++++++++ 6 files changed, 71 insertions(+), 18 deletions(-) diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 5b6a901970..1e5b6b0b40 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -2915,7 +2915,7 @@ nvim_win_set_buf({window}, {buffer}) *nvim_win_set_buf()* Sets the current buffer in a window, without side effects Attributes: ~ - not allowed when |textlock| is active or in the |cmdwin| + not allowed when |textlock| is active Parameters: ~ • {window} Window handle, or 0 for current window @@ -3036,7 +3036,7 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()* < Attributes: ~ - not allowed when |textlock| is active or in the |cmdwin| + not allowed when |textlock| is active Parameters: ~ • {buffer} Buffer to display, or 0 for current buffer diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 8738b3e38e..b4a6fa718b 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -967,7 +967,7 @@ Integer nvim_open_term(Buffer buffer, DictionaryOf(LuaRef) opts, Error *err) } if (cmdwin_type != 0 && buf == curbuf) { - api_set_error(err, kErrorTypeException, "%s", _(e_cmdwin)); + api_set_error(err, kErrorTypeException, "%s", e_cmdwin); return 0; } diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index 6ca36a0daf..81a239d913 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -158,8 +158,17 @@ /// @return Window handle, or 0 on error Window nvim_open_win(Buffer buffer, Boolean enter, Dict(float_config) *config, Error *err) FUNC_API_SINCE(6) - FUNC_API_TEXTLOCK + FUNC_API_TEXTLOCK_ALLOW_CMDWIN { + buf_T *buf = find_buffer_by_handle(buffer, err); + if (!buf) { + return 0; + } + if (cmdwin_type != 0 && (enter || buf == curbuf)) { + api_set_error(err, kErrorTypeException, "%s", e_cmdwin); + return 0; + } + FloatConfig fconfig = FLOAT_CONFIG_INIT; if (!parse_float_config(config, &fconfig, false, true, err)) { return 0; @@ -173,7 +182,7 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(float_config) *config, E } // autocmds in win_enter or win_set_buf below may close the window if (win_valid(wp) && buffer > 0) { - win_set_buf(wp->handle, buffer, fconfig.noautocmd, err); + win_set_buf(wp, buf, fconfig.noautocmd, err); } if (!win_valid(wp)) { api_set_error(err, kErrorTypeException, "Window was closed immediately"); diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 5480584aa5..666f09e890 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -50,9 +50,18 @@ Buffer nvim_win_get_buf(Window window, Error *err) /// @param[out] err Error details, if any void nvim_win_set_buf(Window window, Buffer buffer, Error *err) FUNC_API_SINCE(5) - FUNC_API_TEXTLOCK + FUNC_API_TEXTLOCK_ALLOW_CMDWIN { - win_set_buf(window, buffer, false, err); + win_T *win = find_window_by_handle(window, err); + buf_T *buf = find_buffer_by_handle(buffer, err); + if (!win || !buf) { + return; + } + if (cmdwin_type != 0 && (win == curwin || buf == curbuf)) { + api_set_error(err, kErrorTypeException, "%s", e_cmdwin); + return; + } + win_set_buf(win, buf, false, err); } /// Gets the (1,0)-indexed, buffer-relative cursor position for a given window @@ -396,7 +405,7 @@ void nvim_win_close(Window window, Boolean force, Error *err) if (win == curwin) { cmdwin_result = Ctrl_C; } else { - api_set_error(err, kErrorTypeException, "%s", _(e_cmdwin)); + api_set_error(err, kErrorTypeException, "%s", e_cmdwin); } return; } diff --git a/src/nvim/window.c b/src/nvim/window.c index e230bde95c..fa7ca53b08 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -698,15 +698,9 @@ static void cmd_with_count(char *cmd, char *bufp, size_t bufsize, int64_t Prenum } } -void win_set_buf(Window window, Buffer buffer, bool noautocmd, Error *err) +void win_set_buf(win_T *win, buf_T *buf, bool noautocmd, Error *err) + FUNC_ATTR_NONNULL_ALL { - win_T *win = find_window_by_handle(window, err); - buf_T *buf = find_buffer_by_handle(buffer, err); - - if (!win || !buf) { - return; - } - tabpage_T *tab = win_find_tabpage(win); // no redrawing and don't set the window title @@ -720,7 +714,7 @@ void win_set_buf(Window window, Buffer buffer, bool noautocmd, Error *err) api_set_error(err, kErrorTypeException, "Failed to switch to window %d", - window); + win->handle); } try_start(); @@ -729,7 +723,7 @@ void win_set_buf(Window window, Buffer buffer, bool noautocmd, Error *err) api_set_error(err, kErrorTypeException, "Failed to set buffer %d", - buffer); + buf->handle); } // If window is not current, state logic will not validate its cursor. diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 19511f30f1..e7e767817b 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -43,6 +43,22 @@ describe('API/win', function() eq('Invalid buffer id: 23', pcall_err(window, 'set_buf', nvim('get_current_win'), 23)) eq('Invalid window id: 23', pcall_err(window, 'set_buf', 23, nvim('get_current_buf'))) end) + + it('disallowed in cmdwin if win=curwin or buf=curbuf', function() + local new_buf = meths.create_buf(true, true) + local new_win = meths.open_win(new_buf, false, { + relative='editor', row=10, col=10, width=50, height=10, + }) + feed('q:') + eq('E11: Invalid in command-line window; executes, CTRL-C quits', + pcall_err(meths.win_set_buf, 0, new_buf)) + eq('E11: Invalid in command-line window; executes, CTRL-C quits', + pcall_err(meths.win_set_buf, new_win, 0)) + + local next_buf = meths.create_buf(true, true) + meths.win_set_buf(new_win, next_buf) + eq(next_buf, meths.win_get_buf(new_win)) + end) end) describe('{get,set}_cursor', function() @@ -821,6 +837,31 @@ describe('API/win', function() }) eq(1, funcs.exists('g:fired')) end) + + it('disallowed in cmdwin if enter=true or buf=curbuf', function() + local new_buf = meths.create_buf(true, true) + feed('q:') + eq('E11: Invalid in command-line window; executes, CTRL-C quits', + pcall_err(meths.open_win, new_buf, true, { + relative='editor', row=5, col=5, width=5, height=5, + })) + eq('E11: Invalid in command-line window; executes, CTRL-C quits', + pcall_err(meths.open_win, 0, false, { + relative='editor', row=5, col=5, width=5, height=5, + })) + + eq(new_buf, meths.win_get_buf(meths.open_win(new_buf, false, { + relative='editor', row=5, col=5, width=5, height=5, + }))) + end) + + it('aborts if buffer is invalid', function() + local wins_before = meths.list_wins() + eq('Invalid buffer id: 1337', pcall_err(meths.open_win, 1337, false, { + relative='editor', row=5, col=5, width=5, height=5, + })) + eq(wins_before, meths.list_wins()) + end) end) describe('get_config', function() From 5d921e28c1cc33eced22bbfa823460ca241e3dc1 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 23 Jul 2023 23:10:28 +0100 Subject: [PATCH 2/4] feat(api): allow win_close in cmdwin to close wins except previous Disallow closing the previous window from `nvim_win_close`, as this will cause issues. Again, no telling how safe this is. It also requires exposing old_curwin. :/ Also note that it's possible for the `&cmdheight` to change if, for example, there are 2 tabpages and `nvim_win_close` is used to close the last window in the other tabpage while `&stal` is 1. This is addressed in a later commit. --- src/nvim/api/window.c | 5 +++-- src/nvim/ex_getln.c | 3 +++ src/nvim/globals.h | 1 + test/functional/api/window_spec.lua | 14 ++++++++++---- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 666f09e890..350d934825 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -404,10 +404,11 @@ void nvim_win_close(Window window, Boolean force, Error *err) if (cmdwin_type != 0) { if (win == curwin) { cmdwin_result = Ctrl_C; - } else { + return; + } else if (win == cmdwin_old_curwin) { api_set_error(err, kErrorTypeException, "%s", e_cmdwin); + return; } - return; } tabpage_T *tabpage = win_find_tabpage(win); diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 9dcfa99a37..5f1f5d5adc 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4398,6 +4398,7 @@ static int open_cmdwin(void) // Set "cmdwin_type" before any autocommands may mess things up. cmdwin_type = get_cmdline_type(); cmdwin_level = ccline.level; + cmdwin_old_curwin = old_curwin; // Create empty command-line buffer. if (buf_open_scratch(0, _("[Command Line]")) == FAIL) { @@ -4405,6 +4406,7 @@ static int open_cmdwin(void) win_close(curwin, true, false); ga_clear(&winsizes); cmdwin_type = 0; + cmdwin_old_curwin = NULL; return Ctrl_C; } // Command-line buffer has bufhidden=wipe, unlike a true "scratch" buffer. @@ -4501,6 +4503,7 @@ static int open_cmdwin(void) cmdwin_type = 0; cmdwin_level = 0; + cmdwin_old_curwin = NULL; exmode_active = save_exmode; diff --git a/src/nvim/globals.h b/src/nvim/globals.h index dc7753f222..a1156a0196 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -831,6 +831,7 @@ EXTERN bool km_startsel INIT(= false); EXTERN int cmdwin_type INIT(= 0); ///< type of cmdline window or 0 EXTERN int cmdwin_result INIT(= 0); ///< result of cmdline window or 0 EXTERN int cmdwin_level INIT(= 0); ///< cmdline recursion level +EXTERN win_T *cmdwin_old_curwin INIT(= NULL); ///< curwin before opening cmdline window or NULL EXTERN char no_lines_msg[] INIT(= N_("--No lines in buffer--")); diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index e7e767817b..74aaae0c6f 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -540,15 +540,21 @@ describe('API/win', function() command('split') eq(2, #meths.list_wins()) local oldwin = meths.get_current_win() + local otherwin = meths.open_win(0, false, { + relative='editor', row=10, col=10, width=10, height=10, + }) -- Open cmdline-window. feed('q:') - eq(3, #meths.list_wins()) + eq(4, #meths.list_wins()) eq(':', funcs.getcmdwintype()) - -- Vim: not allowed to close other windows from cmdline-window. + -- Not allowed to close previous window from cmdline-window. eq('E11: Invalid in command-line window; executes, CTRL-C quits', - pcall_err(meths.win_close, oldwin, true)) + pcall_err(meths.win_close, oldwin, true)) + -- Closing other windows is fine. + meths.win_close(otherwin, true) + eq(false, meths.win_is_valid(otherwin)) -- Close cmdline-window. - meths.win_close(0,true) + meths.win_close(0, true) eq(2, #meths.list_wins()) eq('', funcs.getcmdwintype()) end) From 472271199e483d3f23d62c272b20c5290eec5474 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 24 Jul 2023 14:19:01 +0100 Subject: [PATCH 3/4] feat(api): allow win_hide to close cmdwin or non-previous windows This aligns its behaviour better with `nvim_win_close`. Note that `:hide` is actually incapable of closing the cmdwin, unlike `:close` and `:quit`, so this is a bit of a difference in behaviour. --- runtime/doc/api.txt | 2 +- src/nvim/api/window.c | 16 +++------------- src/nvim/window.c | 17 +++++++++++++++++ test/functional/api/window_spec.lua | 18 ++++++++++++++++++ .../vimscript/api_functions_spec.lua | 3 ++- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 1e5b6b0b40..417137c166 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -2897,7 +2897,7 @@ nvim_win_hide({window}) *nvim_win_hide()* or |nvim_win_close()|, which will close the buffer. Attributes: ~ - not allowed when |textlock| is active or in the |cmdwin| + not allowed when |textlock| is active Parameters: ~ • {window} Window handle, or 0 for current window diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 350d934825..f32a7e671d 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -362,10 +362,10 @@ Boolean nvim_win_is_valid(Window window) /// @param[out] err Error details, if any void nvim_win_hide(Window window, Error *err) FUNC_API_SINCE(7) - FUNC_API_TEXTLOCK + FUNC_API_TEXTLOCK_ALLOW_CMDWIN { win_T *win = find_window_by_handle(window, err); - if (!win) { + if (!win || !can_close_in_cmdwin(win, err)) { return; } @@ -397,20 +397,10 @@ void nvim_win_close(Window window, Boolean force, Error *err) FUNC_API_TEXTLOCK_ALLOW_CMDWIN { win_T *win = find_window_by_handle(window, err); - if (!win) { + if (!win || !can_close_in_cmdwin(win, err)) { return; } - if (cmdwin_type != 0) { - if (win == curwin) { - cmdwin_result = Ctrl_C; - return; - } else if (win == cmdwin_old_curwin) { - api_set_error(err, kErrorTypeException, "%s", e_cmdwin); - return; - } - } - tabpage_T *tabpage = win_find_tabpage(win); TryState tstate; try_enter(&tstate); diff --git a/src/nvim/window.c b/src/nvim/window.c index fa7ca53b08..d55bda18c8 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2670,6 +2670,23 @@ static bool can_close_floating_windows(void) return true; } +/// @return true if, considering the cmdwin, `win` is safe to close. +/// If false and `win` is the cmdwin, it is closed; otherwise, `err` is set. +bool can_close_in_cmdwin(win_T *win, Error *err) + FUNC_ATTR_NONNULL_ALL +{ + if (cmdwin_type != 0) { + if (win == curwin) { + cmdwin_result = Ctrl_C; + return false; + } else if (win == cmdwin_old_curwin) { + api_set_error(err, kErrorTypeException, "%s", e_cmdwin); + return false; + } + } + return true; +} + /// Close the possibly last window in a tab page. /// /// @param win window to close diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 74aaae0c6f..00896a97d8 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -615,6 +615,24 @@ describe('API/win', function() eq({oldwin}, meths.list_wins()) eq({oldbuf}, meths.list_bufs()) end) + it('in the cmdwin', function() + feed('q:') + -- Can close the cmdwin. + meths.win_hide(0) + eq('', funcs.getcmdwintype()) + + local old_win = meths.get_current_win() + local other_win = meths.open_win(0, false, { + relative='win', row=3, col=3, width=12, height=3 + }) + feed('q:') + -- Cannot close the previous window. + eq('E11: Invalid in command-line window; executes, CTRL-C quits', + pcall_err(meths.win_hide, old_win)) + -- Can close other windows. + meths.win_hide(other_win) + eq(false, meths.win_is_valid(other_win)) + end) end) describe('text_height', function() diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 6548548a9e..0a7e7c1137 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -73,9 +73,10 @@ describe('eval-API', function() -- Some functions checking textlock (usually those that may change the current window or buffer) -- also ought to not be usable in the cmdwin. + local old_win = meths.get_current_win() feed("q:") eq('E11: Invalid in command-line window; executes, CTRL-C quits', - pcall_err(meths.win_hide, 0)) + pcall_err(meths.set_current_win, old_win)) -- But others, like nvim_buf_set_lines(), which just changes text, is OK. curbufmeths.set_lines(0, -1, 1, {"wow!"}) From a47be0b2d90b26905866faf5b7cc82d9c17be9bb Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 24 Jul 2023 11:56:26 +0100 Subject: [PATCH 4/4] fix(window): prevent win_size_restore from changing cmdheight Currently it only skips if `Rows` changed, but it's possible for the height of the usable area for windows to change (e.g: via `&ch`, `&stal` or `&ls`), which can cause the value of `&cmdheight` to change when the sizes are restored. This is a Vim bug, so I've submitted a PR there too. No telling when it'll be merged though, given the current lack of activity there. `ROWS_AVAIL` is convenient here, but also subtracts the `global_stl_height()`. Not ideal, as we also care about the height of the last statusline for other values of `&ls`. Meh. Introduce `last_stl_height` for getting the height of the last statusline and use it in `win_size_save/restore` and `last_status` (means `last_status_rec`'s `statusline` argument will now be true if `&ls` is 3, but that does not change the behaviour). Also corrects the logic in `comp_col` to not assume there's a last statusline if `&ls` is 1 and the last window is floating. --- src/nvim/drawscreen.c | 2 +- src/nvim/window.c | 21 +++++++++++++----- test/functional/ui/cmdline_spec.lua | 34 ++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 1554a9304d..73dd584fb1 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -1137,7 +1137,7 @@ static void recording_mode(int attr) /// of 'ru_col'. void comp_col(void) { - int last_has_status = (p_ls > 1 || (p_ls == 1 && !ONE_WINDOW)); + bool last_has_status = last_stl_height(false) > 0; sc_col = 0; ru_col = 0; diff --git a/src/nvim/window.c b/src/nvim/window.c index d55bda18c8..d6d677de3f 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5712,8 +5712,9 @@ void win_size_save(garray_T *gap) { ga_init(gap, (int)sizeof(int), 1); ga_grow(gap, win_count() * 2 + 1); - // first entry is value of 'lines' - ((int *)gap->ga_data)[gap->ga_len++] = Rows; + // first entry is the total lines available for windows + ((int *)gap->ga_data)[gap->ga_len++] = + (int)ROWS_AVAIL + global_stl_height() - last_stl_height(false); FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { ((int *)gap->ga_data)[gap->ga_len++] = @@ -5723,13 +5724,14 @@ void win_size_save(garray_T *gap) } // Restore window sizes, but only if the number of windows is still the same -// and 'lines' didn't change. +// and total lines available for windows didn't change. // Does not free the growarray. void win_size_restore(garray_T *gap) FUNC_ATTR_NONNULL_ALL { if (win_count() * 2 + 1 == gap->ga_len - && ((int *)gap->ga_data)[0] == Rows) { + && ((int *)gap->ga_data)[0] == + (int)ROWS_AVAIL + global_stl_height() - last_stl_height(false)) { // The order matters, because frames contain other frames, but it's // difficult to get right. The easy way out is to do it twice. for (int j = 0; j < 2; j++) { @@ -6993,8 +6995,7 @@ char *file_name_in_line(char *line, int col, int options, int count, char *rel_f void last_status(bool morewin) { // Don't make a difference between horizontal or vertical split. - last_status_rec(topframe, (p_ls == 2 || (p_ls == 1 && (morewin || !one_nonfloat()))), - global_stl_height() > 0); + last_status_rec(topframe, last_stl_height(morewin) > 0, global_stl_height() > 0); } // Remove status line from window, replacing it with a horizontal separator if needed. @@ -7193,6 +7194,14 @@ int global_stl_height(void) return (p_ls == 3) ? STATUS_HEIGHT : 0; } +/// Return the height of the last window's statusline, or the global statusline if set. +/// +/// @param morewin pretend there are two or more windows if true. +int last_stl_height(bool morewin) +{ + return (p_ls > 1 || (p_ls == 1 && (!one_nonfloat() || morewin))) ? STATUS_HEIGHT : 0; +} + /// Return the minimal number of rows that is needed on the screen to display /// the current number of windows. int min_rows(void) diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index dc29b765bd..a8cc8e00f0 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -984,14 +984,46 @@ it('tabline is not redrawn in Ex mode #24122', function() end) describe("cmdline height", function() + before_each(clear) + it("does not crash resized screen #14263", function() - clear() local screen = Screen.new(25, 10) screen:attach() command('set cmdheight=9999') screen:try_resize(25, 5) assert_alive() end) + + it('unchanged when trying to restore window sizes', function() + command('set showtabline=0 cmdheight=2 laststatus=0') + feed('q:') -- Closing cmdwin tries to restore sizes + command('set cmdheight=1 | quit') + eq(1, eval('&cmdheight')) + + command('set showtabline=2 cmdheight=3') + feed('q:') + command('set showtabline=0 | quit') + eq(3, eval('&cmdheight')) + + command('set cmdheight=1 laststatus=2') + feed('q:') + command('set laststatus=0 | quit') + eq(1, eval('&cmdheight')) + + command('set laststatus=2') + feed('q:') + command('set laststatus=1 | quit') + eq(1, eval('&cmdheight')) + + command('set laststatus=2 | belowright vsplit | wincmd _') + local restcmds = eval('winrestcmd()') + feed('q:') + command('set laststatus=1 | quit') + -- As we have 2 windows, &ls = 1 should still have a statusline on the last + -- window. As such, the number of available rows hasn't changed and the window + -- sizes should be restored. + eq(restcmds, eval('winrestcmd()')) + end) end) describe('cmdheight=0', function()