vim-patch:9.0.0114: the command line takes up space even when not used

Problem:    The command line takes up space even when not used.
Solution:   Allow for 'cmdheight' to be set to zero. (Shougo Matsushita,
            closes vim/vim#10675, closes vim/vim#940)
f39cfb7262

Omit win_redr_ruler() change: winbar may still need redraw.
Omit win_update() changes: Nvim doesn't use `Rows` there.
Omit redraw_asap(): removed.
This commit is contained in:
Shougo Matsushita 2022-07-31 17:06:32 +09:00 committed by zeertzjq
parent abc087f4c6
commit 81a1d26c3e
9 changed files with 68 additions and 26 deletions

View File

@ -1314,14 +1314,14 @@ A jump table for the options with a short description can be found at |Q_op|.
*'cmdheight'* *'ch'* *'cmdheight'* *'ch'*
'cmdheight' 'ch' number (default 1) 'cmdheight' 'ch' number (default 1)
global global or local to tab page
Number of screen lines to use for the command-line. Helps avoiding Number of screen lines to use for the command-line. Helps avoiding
|hit-enter| prompts. |hit-enter| prompts.
The value of this option is stored with the tab page, so that each tab The value of this option is stored with the tab page, so that each tab
page can have a different value. page can have a different value.
When 'cmdheight' is zero, it disables echo area and all outputs need When 'cmdheight' is zero, there is no command-line unless it is being
|hit-enter| prompt. used. Any messages will cause the |hit-enter| prompt.
*'cmdwinheight'* *'cwh'* *'cmdwinheight'* *'cwh'*
'cmdwinheight' 'cwh' number (default 7) 'cmdwinheight' 'cwh' number (default 7)
@ -4850,7 +4850,7 @@ A jump table for the options with a short description can be found at |Q_op|.
If 'rulerformat' is set, it will determine the contents of the ruler. If 'rulerformat' is set, it will determine the contents of the ruler.
Each window has its own ruler. If a window has a status line, the Each window has its own ruler. If a window has a status line, the
ruler is shown there. If a window doesn't have a status line and ruler is shown there. If a window doesn't have a status line and
'cmdheight' is 0, the ruler is not shown. Otherwise it is shown in 'cmdheight' is zero, the ruler is not shown. Otherwise it is shown in
the last line of the screen. If the statusline is given by the last line of the screen. If the statusline is given by
'statusline' (i.e. not empty), this option takes precedence over 'statusline' (i.e. not empty), this option takes precedence over
'ruler' and 'rulerformat'. 'ruler' and 'rulerformat'.
@ -5559,7 +5559,7 @@ A jump table for the options with a short description can be found at |Q_op|.
global global
Show (partial) command in the last line of the screen. Set this Show (partial) command in the last line of the screen. Set this
option off if your terminal is slow. option off if your terminal is slow.
The option is disabled if 'cmdheight' is 0. The option has no effect when 'cmdheight' is zero.
In Visual mode the size of the selected area is shown: In Visual mode the size of the selected area is shown:
- When selecting characters within a line, the number of characters. - When selecting characters within a line, the number of characters.
If the number of bytes is different it is also displayed: "2-6" If the number of bytes is different it is also displayed: "2-6"
@ -5606,7 +5606,7 @@ A jump table for the options with a short description can be found at |Q_op|.
global global
If in Insert, Replace or Visual mode put a message on the last line. If in Insert, Replace or Visual mode put a message on the last line.
The |hl-ModeMsg| highlight group determines the highlighting. The |hl-ModeMsg| highlight group determines the highlighting.
The option is disabled if 'cmdheight' is 0. The option has no effect when 'cmdheight' is zero.
*'showtabline'* *'stal'* *'showtabline'* *'stal'*
'showtabline' 'stal' number (default 1) 'showtabline' 'stal' number (default 1)

View File

@ -3669,7 +3669,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
} }
} }
bool cmdheight0 = !ui_has_messages(); const bool cmdheight0 = !ui_has_messages();
if (cmdheight0) { if (cmdheight0) {
// If cmdheight is 0, cmdheight must be set to 1 when we enter command line. // If cmdheight is 0, cmdheight must be set to 1 when we enter command line.
set_option_value("ch", 1L, NULL, 0); set_option_value("ch", 1L, NULL, 0);

View File

@ -689,7 +689,7 @@ static void finish_incsearch_highlighting(int gotesc, incsearch_state_T *s, bool
/// @param init_ccline clear ccline first /// @param init_ccline clear ccline first
static uint8_t *command_line_enter(int firstc, long count, int indent, bool init_ccline) static uint8_t *command_line_enter(int firstc, long count, int indent, bool init_ccline)
{ {
bool cmdheight0 = !ui_has_messages(); const bool cmdheight0 = !ui_has_messages();
if (cmdheight0) { if (cmdheight0) {
// If cmdheight is 0, cmdheight must be set to 1 when we enter command line. // If cmdheight is 0, cmdheight must be set to 1 when we enter command line.
@ -993,7 +993,6 @@ theend:
if (cmdheight0) { if (cmdheight0) {
// Restore cmdheight // Restore cmdheight
set_option_value("ch", 0L, NULL, 0); set_option_value("ch", 0L, NULL, 0);
// Redraw is needed for command line completion // Redraw is needed for command line completion
redraw_all_later(CLEAR); redraw_all_later(CLEAR);
} }

View File

@ -1390,7 +1390,7 @@ void msg_start(void)
need_fileinfo = false; need_fileinfo = false;
} }
bool no_msg_area = !ui_has_messages(); const bool no_msg_area = !ui_has_messages();
if (need_clr_eos || (no_msg_area && redrawing_cmdline)) { if (need_clr_eos || (no_msg_area && redrawing_cmdline)) {
// Halfway an ":echo" command and getting an (error) message: clear // Halfway an ":echo" command and getting an (error) message: clear

View File

@ -893,7 +893,7 @@ int do_record(int c)
{ {
char_u *p; char_u *p;
static int regname; static int regname;
static bool change_cmdheight = false; static bool changed_cmdheight = false;
yankreg_T *old_y_previous; yankreg_T *old_y_previous;
int retval; int retval;
@ -907,13 +907,15 @@ int do_record(int c)
showmode(); showmode();
regname = c; regname = c;
retval = OK; retval = OK;
if (!ui_has_messages()) { if (!ui_has_messages()) {
// Enable macro indicator temporary // Enable macro indicator temporary
set_option_value("ch", 1L, NULL, 0); set_option_value("ch", 1L, NULL, 0);
update_screen(VALID); update_screen(VALID);
change_cmdheight = true; changed_cmdheight = true;
} }
apply_autocmds(EVENT_RECORDINGENTER, NULL, NULL, false, curbuf); apply_autocmds(EVENT_RECORDINGENTER, NULL, NULL, false, curbuf);
} }
} else { // stop recording } else { // stop recording
@ -936,15 +938,6 @@ int do_record(int c)
(void)tv_dict_add_str(dict, S_LEN("regname"), buf); (void)tv_dict_add_str(dict, S_LEN("regname"), buf);
tv_dict_set_keys_readonly(dict); tv_dict_set_keys_readonly(dict);
if (change_cmdheight) {
// Restore cmdheight
set_option_value("ch", 0L, NULL, 0);
redraw_all_later(CLEAR);
change_cmdheight = false;
}
// Get the recorded key hits. K_SPECIAL will be escaped, this // Get the recorded key hits. K_SPECIAL will be escaped, this
// needs to be removed again to put it in a register. exec_reg then // needs to be removed again to put it in a register. exec_reg then
// adds the escaping back later. // adds the escaping back later.
@ -968,6 +961,12 @@ int do_record(int c)
y_previous = old_y_previous; y_previous = old_y_previous;
} }
if (changed_cmdheight) {
// Restore cmdheight
set_option_value("ch", 0L, NULL, 0);
redraw_all_later(CLEAR);
}
} }
return retval; return retval;
} }

View File

@ -6501,7 +6501,7 @@ static void win_redr_ruler(win_T *wp, bool always)
bool is_stl_global = global_stl_height() > 0; bool is_stl_global = global_stl_height() > 0;
static bool did_show_ext_ruler = false; static bool did_show_ext_ruler = false;
// If 'ruler' off or redrawing disabled, don't do anything // If 'ruler' off, don't do anything
if (!p_ru) { if (!p_ru) {
return; return;
} }

View File

@ -316,4 +316,51 @@ func Test_fileinfo_after_echo()
call delete('b.txt') call delete('b.txt')
endfunc endfunc
func Test_cmdheight_zero()
set cmdheight=0
set showcmd
redraw!
echo 'test echo'
call assert_equal(116, screenchar(&lines, 1))
redraw!
echomsg 'test echomsg'
call assert_equal(116, screenchar(&lines, 1))
redraw!
call feedkeys(":ls\<CR>", "xt")
call assert_equal(':ls', Screenline(&lines - 1))
redraw!
let char = getchar(0)
call assert_match(char, 0)
" Check change/restore cmdheight when macro
call feedkeys("qa", "xt")
call assert_equal(&cmdheight, 1)
call feedkeys("q", "xt")
call assert_equal(&cmdheight, 0)
call setline(1, 'somestring')
call feedkeys("y", "n")
%s/somestring/otherstring/gc
call assert_equal(getline(1), 'otherstring')
call feedkeys("g\<C-g>", "xt")
call assert_match(
\ 'Col 1 of 11; Line 1 of 1; Word 1 of 1',
\ Screenline(&lines))
" Check split behavior
for i in range(1, 10)
split
endfor
only
call assert_equal(&cmdheight, 0)
set cmdheight&
set showcmd&
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@ -1390,11 +1390,9 @@ func Test_win_move_statusline()
call assert_equal(h0, winheight(0)) call assert_equal(h0, winheight(0))
call assert_equal(1, &cmdheight) call assert_equal(1, &cmdheight)
endfor endfor
" Nvim supports cmdheight=0 " supports cmdheight=0
set cmdheight=0 set cmdheight=0
call assert_true(win_move_statusline(0, 1)) call assert_true(win_move_statusline(0, 1))
"call assert_equal(h0, winheight(0))
"call assert_equal(1, &cmdheight)
call assert_equal(h0 + 1, winheight(0)) call assert_equal(h0 + 1, winheight(0))
call assert_equal(0, &cmdheight) call assert_equal(0, &cmdheight)
set cmdheight& set cmdheight&

View File

@ -5555,7 +5555,6 @@ static void frame_setheight(frame_T *curfrp, int height)
} }
if (curfrp->fr_parent == NULL) { if (curfrp->fr_parent == NULL) {
// topframe: can only change the command line
if (height > ROWS_AVAIL) { if (height > ROWS_AVAIL) {
// If height is greater than the available space, try to create space for // If height is greater than the available space, try to create space for
// the frame by reducing 'cmdheight' if possible, while making sure // the frame by reducing 'cmdheight' if possible, while making sure