diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 53c903d8d7..332e1c2261 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -5241,7 +5241,13 @@ void ins_compl_insert(bool move_cursor, bool insert_prefix) static void ins_compl_show_filename(void) { char *const lead = _("match in file"); - int space = sc_col - vim_strsize(lead) - 2; + + // In the case of ext_messages, `sc_col` is obsolete. Fortunately, long messages are no longer + // disruptive, so truncation could be skipped. But in this particular case, with default + // configuration `showmode cmdheight=1`, a multi-line message is shown partially, and a message + // that fits into one line is not shown at all. It's better to be consistent: it should not depend + // on the exact length of the message whether it is displayed at all. + int space = (ui_has(kUIMessages) ? Columns : sc_col) - vim_strsize(lead) - 2; if (space <= 0) { return; } diff --git a/src/nvim/message.c b/src/nvim/message.c index 684ccaeb25..d9f5111633 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -519,7 +519,12 @@ char *msg_strtrunc(const char *s, int force) room = (Rows - msg_row) * Columns - 1; } else { // Use up to 'showcmd' column. - room = (Rows - msg_row - 1) * Columns + sc_col - 1; + // In the case of ui2, we no longer need to avoid the "Press ENTER" prompt, but the message is + // still kept under 1 line to avoid glitches. For example, when a long search term is + // displayed that expands the cmdline, it will be immediately collapsed again when the search + // count is displayed, which leads to flickering on each hit. + int last_row = ui_has(kUIMessages) ? Columns : sc_col - 1; + room = (Rows - msg_row - 1) * Columns + last_row; } if (len > room && room > 0) { // may have up to 18 bytes per cell (6 per char, up to two