cmdheight=0: fix bugs part2 (#19185)

This commit is contained in:
Shougo 2022-07-31 14:13:19 +09:00 committed by GitHub
parent 7f4c50f8c4
commit c1652bdcb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 42 additions and 20 deletions

View File

@ -2899,6 +2899,11 @@ static void getchar_common(typval_T *argvars, typval_T *rettv)
no_mapping--; no_mapping--;
allow_keys--; allow_keys--;
if (!ui_has_messages()) {
// redraw the screen after getchar()
update_screen(CLEAR);
}
set_vim_var_nr(VV_MOUSE_WIN, 0); set_vim_var_nr(VV_MOUSE_WIN, 0);
set_vim_var_nr(VV_MOUSE_WINID, 0); set_vim_var_nr(VV_MOUSE_WINID, 0);
set_vim_var_nr(VV_MOUSE_LNUM, 0); set_vim_var_nr(VV_MOUSE_LNUM, 0);

View File

@ -3669,7 +3669,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
} }
} }
bool cmdheight0 = p_ch < 1 && !ui_has(kUIMessages); 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 = p_ch < 1 && !ui_has(kUIMessages); 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.

View File

@ -493,6 +493,7 @@ int smsg(const char *s, ...)
va_start(arglist, s); va_start(arglist, s);
vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist); vim_vsnprintf((char *)IObuff, IOSIZE, s, arglist);
va_end(arglist); va_end(arglist);
return msg((char *)IObuff); return msg((char *)IObuff);
} }
@ -1389,7 +1390,7 @@ void msg_start(void)
need_fileinfo = false; need_fileinfo = false;
} }
bool no_msg_area = !ui_has(kUIMessages) && p_ch < 1; 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
@ -3112,7 +3113,7 @@ void msg_clr_eos_force(void)
msg_row = msg_grid_pos; msg_row = msg_grid_pos;
} }
if (p_ch > 0) { if (ui_has_messages()) {
grid_fill(&msg_grid_adj, msg_row, msg_row + 1, msg_startcol, msg_endcol, grid_fill(&msg_grid_adj, msg_row, msg_row + 1, msg_startcol, msg_endcol,
' ', ' ', HL_ATTR(HLF_MSG)); ' ', ' ', HL_ATTR(HLF_MSG));
grid_fill(&msg_grid_adj, msg_row + 1, Rows, 0, Columns, grid_fill(&msg_grid_adj, msg_row + 1, Rows, 0, Columns,

View File

@ -2810,7 +2810,7 @@ void pop_showcmd(void)
static void display_showcmd(void) static void display_showcmd(void)
{ {
if (p_ch < 1 && !ui_has(kUIMessages)) { if (!ui_has_messages()) {
return; return;
} }

View File

@ -893,6 +893,7 @@ int do_record(int c)
{ {
char_u *p; char_u *p;
static int regname; static int regname;
static bool change_cmdheight = false;
yankreg_T *old_y_previous; yankreg_T *old_y_previous;
int retval; int retval;
@ -906,6 +907,13 @@ int do_record(int c)
showmode(); showmode();
regname = c; regname = c;
retval = OK; retval = OK;
if (!ui_has_messages()) {
// Enable macro indicator temporary
set_option_value("ch", 1L, NULL, 0);
update_screen(VALID);
change_cmdheight = true;
}
apply_autocmds(EVENT_RECORDINGENTER, NULL, NULL, false, curbuf); apply_autocmds(EVENT_RECORDINGENTER, NULL, NULL, false, curbuf);
} }
} else { // stop recording } else { // stop recording
@ -928,6 +936,15 @@ 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.
@ -2789,7 +2806,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
xfree(reg->y_array); xfree(reg->y_array);
} }
if (message && (p_ch > 0 || ui_has(kUIMessages))) { // Display message about yank? if (message) { // Display message about yank?
if (yank_type == kMTCharWise && yanklines == 1) { if (yank_type == kMTCharWise && yanklines == 1) {
yanklines = 0; yanklines = 0;
} }

View File

@ -6143,10 +6143,6 @@ void unshowmode(bool force)
// Clear the mode message. // Clear the mode message.
void clearmode(void) void clearmode(void)
{ {
if (p_ch <= 0 && !ui_has(kUIMessages)) {
return;
}
const int save_msg_row = msg_row; const int save_msg_row = msg_row;
const int save_msg_col = msg_col; const int save_msg_col = msg_col;
@ -6164,10 +6160,6 @@ void clearmode(void)
static void recording_mode(int attr) static void recording_mode(int attr)
{ {
if (p_ch <= 0 && !ui_has(kUIMessages)) {
return;
}
msg_puts_attr(_("recording"), attr); msg_puts_attr(_("recording"), attr);
if (!shortmess(SHM_RECORDING)) { if (!shortmess(SHM_RECORDING)) {
char s[4]; char s[4];
@ -6472,8 +6464,7 @@ int redrawing(void)
*/ */
int messaging(void) int messaging(void)
{ {
return !(p_lz && char_avail() && !KeyTyped) return !(p_lz && char_avail() && !KeyTyped) && ui_has_messages();
&& (p_ch > 0 || ui_has(kUIMessages));
} }
/// Show current status info in ruler and various other places /// Show current status info in ruler and various other places
@ -6587,7 +6578,7 @@ static void win_redr_ruler(win_T *wp, bool always)
off = 0; off = 0;
} }
if (!part_of_status && p_ch < 1 && !ui_has(kUIMessages)) { if (!part_of_status && !ui_has_messages()) {
return; return;
} }

View File

@ -612,6 +612,12 @@ bool ui_has(UIExtension ext)
return ui_ext[ext]; return ui_ext[ext];
} }
/// Returns true if the UI has messages area.
bool ui_has_messages(void)
{
return p_ch > 0 || ui_has(kUIMessages);
}
Array ui_array(void) Array ui_array(void)
{ {
Array all_uis = ARRAY_DICT_INIT; Array all_uis = ARRAY_DICT_INIT;

View File

@ -5877,7 +5877,7 @@ void win_setminheight(void)
// loop until there is a 'winminheight' that is possible // loop until there is a 'winminheight' that is possible
while (p_wmh > 0) { while (p_wmh > 0) {
const int room = Rows - (int)p_ch; const int room = Rows - (int)p_ch;
const int needed = min_rows() - 1; // 1 was added for the cmdline const int needed = min_rows();
if (room >= needed) { if (room >= needed) {
break; break;
} }
@ -6830,7 +6830,9 @@ int min_rows(void)
} }
} }
total += tabline_height() + global_stl_height(); total += tabline_height() + global_stl_height();
total += 1; // count the room for the command line if (p_ch > 0) {
total += 1; // count the room for the command line
}
return total; return total;
} }

View File

@ -1103,7 +1103,7 @@ describe('cmdheight=0', function()
~ | ~ |
~ | ~ |
~ | ~ |
~ | recording @q |
]], showmode={}} ]], showmode={}}
feed('q') feed('q')
screen:expect{grid=[[ screen:expect{grid=[[