mirror of
https://github.com/neovim/neovim.git
synced 2026-08-28 10:01:49 +00:00
Merge #40621 fix(ui2)!: legacy 'ruler' inconsistencies
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -511,7 +511,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
|
||||
|
||||
@@ -7072,6 +7072,13 @@ local options = {
|
||||
Example: >vim
|
||||
set rulerformat=%15(%c%V\ %p%%%)
|
||||
<
|
||||
This looks like an item group, but there are some differences in this
|
||||
particular case. Most notably, the width is fixed and not a minimum,
|
||||
and the ruler is left-aligned, whereas the alignment of item groups is
|
||||
configurable and right-aligned by default.
|
||||
|
||||
When |ui2| is enabled, the ruler no longer has a fixed width and the
|
||||
item group syntax has no special meaning for 'rulerformat'.
|
||||
]=],
|
||||
full_name = 'rulerformat',
|
||||
modelineexpr = true,
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "nvim/tag.h"
|
||||
#include "nvim/terminal.h"
|
||||
#include "nvim/types_defs.h"
|
||||
#include "nvim/ui.h"
|
||||
#include "nvim/vim_defs.h"
|
||||
#include "nvim/window.h"
|
||||
#include "nvim/winfloat.h"
|
||||
@@ -1917,7 +1918,7 @@ static const char *did_set_statustabline_rulerformat(optset_T *args, bool rulerf
|
||||
win_config_float(win, win->w_config);
|
||||
}
|
||||
|
||||
if (rulerformat && *s == '%') {
|
||||
if (rulerformat && !ui_has(kUIMessages) && *s == '%') {
|
||||
// set ru_wid if 'ruf' starts with "%99("
|
||||
if (*++s == '-') { // ignore a '-'
|
||||
s++;
|
||||
@@ -1932,8 +1933,8 @@ static const char *did_set_statustabline_rulerformat(optset_T *args, bool rulerf
|
||||
errmsg = check_stl_option(p_ruf);
|
||||
}
|
||||
}
|
||||
} else if (rulerformat || s[0] != '%' || s[1] != '!') {
|
||||
// check 'statusline', 'winbar', 'tabline' or 'statuscolumn'
|
||||
} else if (s[0] != '%' || s[1] != '!') {
|
||||
// check 'statusline', 'rulerformat', 'winbar', 'tabline' or 'statuscolumn'
|
||||
// only if it doesn't start with "%!"
|
||||
errmsg = check_stl_option(s);
|
||||
}
|
||||
|
||||
@@ -308,7 +308,15 @@ static void win_redr_stl_expr(win_T *wp, bool draw_winbar, bool draw_ruler, bool
|
||||
wp->w_status_click_defs = stl_alloc_click_defs(wp->w_status_click_defs, maxwidth,
|
||||
&wp->w_status_click_defs_size);
|
||||
|
||||
if (draw_ruler) {
|
||||
if (draw_ruler && ui_event) {
|
||||
stl = p_ruf;
|
||||
opt_idx = kOptRulerformat;
|
||||
maxwidth = Columns / 2;
|
||||
if (!in_status_line) {
|
||||
fillchar = schar_from_ascii(' ');
|
||||
group = HLF_MSG;
|
||||
}
|
||||
} else if (draw_ruler) {
|
||||
stl = p_ruf;
|
||||
opt_idx = kOptRulerformat;
|
||||
// advance past any leading group spec - implicit in ru_col
|
||||
@@ -549,8 +557,8 @@ void redraw_ruler(void)
|
||||
char rel_pos[RULER_BUF_LEN];
|
||||
int rel_poslen = get_rel_pos(wp, rel_pos, RULER_BUF_LEN);
|
||||
int n1 = bufferlen + vim_strsize(rel_pos);
|
||||
if (wp->w_status_height == 0 && !is_stl_global) { // can't use last char of screen
|
||||
n1++;
|
||||
if (wp->w_status_height == 0 && !is_stl_global && !ui_has(kUIMessages)) {
|
||||
n1++; // can't use last char of screen
|
||||
}
|
||||
|
||||
int this_ru_col = ru_col - (Columns - width);
|
||||
@@ -1464,9 +1472,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
|
||||
}
|
||||
}
|
||||
|
||||
// Bound the minimum width at 50.
|
||||
// Make the number negative to denote left alignment of the item
|
||||
minwid = (minwid > 50 ? 50 : minwid) * (left_align ? -1 : 1);
|
||||
minwid *= left_align ? -1 : 1;
|
||||
|
||||
// Denotes the start of a new group
|
||||
if (*fmt_p == '(') {
|
||||
|
||||
@@ -145,7 +145,7 @@ M.vars = {
|
||||
desc = [=[
|
||||
Number of screen cells that can be used for an `:echo` message
|
||||
in the last screen line before causing the |hit-enter| prompt
|
||||
(or "overflow" with |ui2|).
|
||||
(no longer applicable when |ui2| is enabled).
|
||||
|
||||
Depends on 'showcmd', 'ruler' and 'columns'. You need to
|
||||
check 'cmdheight' for whether there are full-width lines
|
||||
|
||||
Reference in New Issue
Block a user