mirror of
https://github.com/neovim/neovim.git
synced 2025-09-20 10:18:18 +00:00
cmdheight=0: fix bugs #18961
Continue of #16251 Fix #18953 Fix #18960 Fix #18958 Fix #18955 Fix #18970 Fix #18983 Fix #18995 Fix #19112
This commit is contained in:
@@ -3651,6 +3651,13 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
|
||||
sub_needs_free = cmdpreview && sub != source;
|
||||
}
|
||||
|
||||
bool cmdheight0 = p_ch < 1 && !ui_has(kUIMessages);
|
||||
if (cmdheight0) {
|
||||
// If cmdheight is 0, cmdheight must be set to 1 when we enter command line.
|
||||
set_option_value("ch", 1L, NULL, 0);
|
||||
redraw_statuslines();
|
||||
}
|
||||
|
||||
// Check for a match on each line.
|
||||
// If preview: limit to max('cmdwinheight', viewport).
|
||||
linenr_T line2 = eap->line2;
|
||||
@@ -4461,6 +4468,11 @@ skip:
|
||||
}
|
||||
}
|
||||
|
||||
if (cmdheight0) {
|
||||
// Restore cmdheight
|
||||
set_option_value("ch", 0L, NULL, 0);
|
||||
}
|
||||
|
||||
kv_destroy(preview_lines.subresults);
|
||||
return retv;
|
||||
#undef ADJUST_SUB_FIRSTLNUM
|
||||
|
@@ -688,12 +688,12 @@ static void finish_incsearch_highlighting(int gotesc, incsearch_state_T *s, bool
|
||||
/// @param init_ccline clear ccline first
|
||||
static uint8_t *command_line_enter(int firstc, long count, int indent, bool init_ccline)
|
||||
{
|
||||
bool cmdheight0 = p_ch < 1 && !ui_has(kUIMessages) && vpeekc() == NUL;
|
||||
bool cmdheight0 = p_ch < 1 && !ui_has(kUIMessages);
|
||||
|
||||
if (cmdheight0) {
|
||||
// If cmdheight is 0, cmdheight must be set to 1 when we enter command line.
|
||||
set_option_value("ch", 1L, NULL, 0);
|
||||
redraw_statuslines();
|
||||
update_screen(VALID); // redraw the screen NOW
|
||||
}
|
||||
|
||||
// can be invoked recursively, identify each level
|
||||
@@ -985,6 +985,9 @@ theend:
|
||||
if (cmdheight0) {
|
||||
// Restore cmdheight
|
||||
set_option_value("ch", 0L, NULL, 0);
|
||||
|
||||
// Redraw is needed for command line completion
|
||||
redraw_all_later(CLEAR);
|
||||
}
|
||||
|
||||
return p;
|
||||
|
@@ -891,7 +891,7 @@ char_u *msg_may_trunc(bool force, char_u *s)
|
||||
|
||||
room = (Rows - cmdline_row - 1) * Columns + sc_col - 1;
|
||||
if ((force || (shortmess(SHM_TRUNC) && !exmode_active))
|
||||
&& (int)STRLEN(s) - room > 0) {
|
||||
&& (int)STRLEN(s) - room > 0 && p_ch > 0) {
|
||||
int size = vim_strsize((char *)s);
|
||||
|
||||
// There may be room anyway when there are multibyte chars.
|
||||
@@ -3083,10 +3083,11 @@ void msg_clr_eos_force(void)
|
||||
msg_row = msg_grid_pos;
|
||||
}
|
||||
|
||||
grid_fill(&msg_grid_adj, msg_row, msg_row + 1, msg_startcol, msg_endcol,
|
||||
' ', ' ', HL_ATTR(HLF_MSG));
|
||||
if (p_ch > 0) {
|
||||
grid_fill(&msg_grid_adj, msg_row + 1, Rows, 0, Columns, ' ', ' ', HL_ATTR(HLF_MSG));
|
||||
grid_fill(&msg_grid_adj, msg_row, msg_row + 1, msg_startcol, msg_endcol,
|
||||
' ', ' ', HL_ATTR(HLF_MSG));
|
||||
grid_fill(&msg_grid_adj, msg_row + 1, Rows, 0, Columns,
|
||||
' ', ' ', HL_ATTR(HLF_MSG));
|
||||
}
|
||||
|
||||
redraw_cmdline = true; // overwritten the command line
|
||||
|
@@ -2791,7 +2791,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
|
||||
xfree(reg->y_array);
|
||||
}
|
||||
|
||||
if (message) { // Display message about yank?
|
||||
if (message && (p_ch > 0 || ui_has(kUIMessages))) { // Display message about yank?
|
||||
if (yank_type == kMTCharWise && yanklines == 1) {
|
||||
yanklines = 0;
|
||||
}
|
||||
|
@@ -6153,6 +6153,10 @@ void clearmode(void)
|
||||
|
||||
static void recording_mode(int attr)
|
||||
{
|
||||
if (p_ch <= 0 && !ui_has(kUIMessages)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg_puts_attr(_("recording"), attr);
|
||||
if (!shortmess(SHM_RECORDING)) {
|
||||
char s[4];
|
||||
@@ -6457,7 +6461,8 @@ int redrawing(void)
|
||||
*/
|
||||
int messaging(void)
|
||||
{
|
||||
return !(p_lz && char_avail() && !KeyTyped);
|
||||
return !(p_lz && char_avail() && !KeyTyped)
|
||||
&& (p_ch > 0 || ui_has(kUIMessages));
|
||||
}
|
||||
|
||||
/// Show current status info in ruler and various other places
|
||||
@@ -6515,7 +6520,7 @@ static void win_redr_ruler(win_T *wp, bool always)
|
||||
}
|
||||
}
|
||||
|
||||
if (*p_ruf) {
|
||||
if (*p_ruf && p_ch > 0 && !ui_has(kUIMessages)) {
|
||||
int save_called_emsg = called_emsg;
|
||||
called_emsg = false;
|
||||
win_redr_custom(wp, false, true);
|
||||
|
@@ -5560,9 +5560,10 @@ static void frame_setheight(frame_T *curfrp, int height)
|
||||
if (curfrp->fr_parent == NULL) {
|
||||
// topframe: can only change the command line
|
||||
if (height > ROWS_AVAIL) {
|
||||
// If height is greater than the available space, try to create space for the frame by
|
||||
// reducing 'cmdheight' if possible, while making sure `cmdheight` doesn't go below 1.
|
||||
height = MIN(ROWS_AVAIL + (p_ch - 1), height);
|
||||
// If height is greater than the available space, try to create space for
|
||||
// the frame by reducing 'cmdheight' if possible, while making sure
|
||||
// `cmdheight` doesn't go below 1.
|
||||
height = MIN((p_ch > 0 ? ROWS_AVAIL + (p_ch - 1) : ROWS_AVAIL), height);
|
||||
}
|
||||
if (height > 0) {
|
||||
frame_new_height(curfrp, height, false, false);
|
||||
|
@@ -949,6 +949,20 @@ describe('cmdheight=0', function()
|
||||
eq(0, eval('&cmdheight'))
|
||||
end)
|
||||
|
||||
it("with cmdheight=0 ruler rulerformat laststatus=0", function()
|
||||
command("set cmdheight=0 noruler laststatus=0 rulerformat=%l,%c%= showmode")
|
||||
feed('i')
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
]], showmode={}}
|
||||
feed('<Esc>')
|
||||
eq(0, eval('&cmdheight'))
|
||||
end)
|
||||
|
||||
it("with showmode", function()
|
||||
command("set cmdheight=1 noruler laststatus=0 showmode")
|
||||
feed('i')
|
||||
@@ -1045,4 +1059,62 @@ describe('cmdheight=0', function()
|
||||
|
||||
assert_alive()
|
||||
end)
|
||||
|
||||
it("when macro with lastline", function()
|
||||
command("set cmdheight=0 display=lastline")
|
||||
feed('qq')
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
]], showmode={}}
|
||||
feed('q')
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
]], showmode={}}
|
||||
end)
|
||||
|
||||
it("when substitute text", function()
|
||||
command("set cmdheight=0 noruler laststatus=3")
|
||||
feed('ifoo<ESC>')
|
||||
screen:expect{grid=[[
|
||||
fo^o |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
[No Name] [+] |
|
||||
]]}
|
||||
|
||||
feed(':%s/foo/bar/gc<CR>')
|
||||
screen:expect{grid=[[
|
||||
foo |
|
||||
~ |
|
||||
~ |
|
||||
[No Name] [+] |
|
||||
replace wi...q/l/^E/^Y)?^ |
|
||||
]]}
|
||||
|
||||
feed('y')
|
||||
screen:expect{grid=[[
|
||||
^bar |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
[No Name] [+] |
|
||||
]]}
|
||||
|
||||
assert_alive()
|
||||
end)
|
||||
|
||||
it("when window resize", function()
|
||||
command("set cmdheight=0")
|
||||
feed('<C-w>+')
|
||||
eq(0, eval('&cmdheight'))
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user