diff options
author | Shougo <Shougo.Matsu@gmail.com> | 2022-07-01 10:59:50 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-30 18:59:50 -0700 |
commit | 5a490d838ed3288abcf45e16e6ab79c326a67c17 (patch) | |
tree | d6084fc7aec13c4324404bb0886ad907c8446ed3 | |
parent | 3b1423bfa7adc5381af641a6e66fa2ca385ecab4 (diff) | |
download | rneovim-5a490d838ed3288abcf45e16e6ab79c326a67c17.tar.gz rneovim-5a490d838ed3288abcf45e16e6ab79c326a67c17.tar.bz2 rneovim-5a490d838ed3288abcf45e16e6ab79c326a67c17.zip |
cmdheight=0: fix bugs #18961
Continue of #16251
Fix #18953
Fix #18960
Fix #18958
Fix #18955
Fix #18970
Fix #18983
Fix #18995
Fix #19112
-rw-r--r-- | src/nvim/ex_cmds.c | 12 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 7 | ||||
-rw-r--r-- | src/nvim/message.c | 9 | ||||
-rw-r--r-- | src/nvim/ops.c | 2 | ||||
-rw-r--r-- | src/nvim/screen.c | 9 | ||||
-rw-r--r-- | src/nvim/window.c | 7 | ||||
-rw-r--r-- | test/functional/ui/cmdline_spec.lua | 72 |
7 files changed, 106 insertions, 12 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 45d08d40bc..82422a78c3 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -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 diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 01f16f3383..49f946d6c0 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -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; diff --git a/src/nvim/message.c b/src/nvim/message.c index 733b4808fe..0cd323c234 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -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 diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 42beb2e16d..639b7fd738 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -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; } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index ea75900ded..bc11883fd8 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -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); diff --git a/src/nvim/window.c b/src/nvim/window.c index 9b9a2126ff..9ac027d80f 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -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); diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 0315d2b479..eb0a14da31 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -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) |