From 5e5cd87aa6a63d2cc38426c2f44e43662717abe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Hoffmann?= Date: Sat, 11 Jul 2026 15:45:34 +0200 Subject: [PATCH] fix(ui2): remove obsolete usages of sc_col Like `v:echospace`, `sc_col` was used in many places to avoid disruptive "Press ENTER" prompts. Since those are no longer a problem with ui2, the complexity of keeping these variables up-to-date and maintaining bespoke truncation code at the message producers is no longer justified. Unfortunately, some messages still need to be kept under 1 line to avoid glitches. `ru_wid`, `ru_col`, and `sc_col` are now no longer used when ui2 is enabled, except `ru_col` in the C implementation of the default ruler, which will be replaced by a default expression. --- src/nvim/insexpand.c | 8 +++++++- src/nvim/message.c | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) 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