mirror of
https://github.com/neovim/neovim.git
synced 2026-04-26 01:04:10 +00:00
fix(statusline): don't show showcmd when not enough space (#21550)
This commit is contained in:
@@ -66,7 +66,6 @@ void win_redr_status(win_T *wp)
|
||||
int len;
|
||||
int fillchar;
|
||||
int attr;
|
||||
int width;
|
||||
int this_ru_col;
|
||||
bool is_stl_global = global_stl_height() > 0;
|
||||
static bool busy = false;
|
||||
@@ -93,7 +92,7 @@ void win_redr_status(win_T *wp)
|
||||
redraw_custom_statusline(wp);
|
||||
} else {
|
||||
fillchar = fillchar_status(&attr, wp);
|
||||
width = is_stl_global ? Columns : wp->w_width;
|
||||
const int stl_width = is_stl_global ? Columns : wp->w_width;
|
||||
|
||||
get_trans_bufname(wp->w_buffer);
|
||||
p = NameBuff;
|
||||
@@ -123,9 +122,9 @@ void win_redr_status(win_T *wp)
|
||||
// len += (int)strlen(p + len); // dead assignment
|
||||
}
|
||||
|
||||
this_ru_col = ru_col - (Columns - width);
|
||||
if (this_ru_col < (width + 1) / 2) {
|
||||
this_ru_col = (width + 1) / 2;
|
||||
this_ru_col = ru_col - (Columns - stl_width);
|
||||
if (this_ru_col < (stl_width + 1) / 2) {
|
||||
this_ru_col = (stl_width + 1) / 2;
|
||||
}
|
||||
if (this_ru_col <= 1) {
|
||||
p = "<"; // No room for file name!
|
||||
@@ -166,9 +165,9 @@ void win_redr_status(win_T *wp)
|
||||
|
||||
// Draw the 'showcmd' information if 'showcmdloc' == "statusline".
|
||||
if (p_sc && *p_sloc == 's') {
|
||||
int sc_width = MIN(10, this_ru_col - len - 2);
|
||||
const int sc_width = MIN(10, this_ru_col - len - 2);
|
||||
|
||||
if (width > 0) {
|
||||
if (sc_width > 0) {
|
||||
grid_puts_len(&default_grid, showcmd_buf, sc_width, row,
|
||||
wp->w_wincol + this_ru_col - sc_width - 1, attr);
|
||||
}
|
||||
@@ -844,11 +843,11 @@ void draw_tabline(void)
|
||||
|
||||
// Draw the 'showcmd' information if 'showcmdloc' == "tabline".
|
||||
if (p_sc && *p_sloc == 't') {
|
||||
int width = MIN(10, (int)Columns - col - (tabcount > 1) * 3);
|
||||
const int sc_width = MIN(10, (int)Columns - col - (tabcount > 1) * 3);
|
||||
|
||||
if (width > 0) {
|
||||
grid_puts_len(&default_grid, showcmd_buf, width, 0,
|
||||
Columns - width - (tabcount > 1) * 2, attr_nosel);
|
||||
if (sc_width > 0) {
|
||||
grid_puts_len(&default_grid, showcmd_buf, sc_width, 0,
|
||||
Columns - sc_width - (tabcount > 1) * 2, attr_nosel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -545,3 +545,29 @@ it('statusline is redrawn with :resize from <Cmd> mapping #19629', function()
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it('showcmdloc=statusline does not show if statusline is too narrow', function()
|
||||
clear()
|
||||
local screen = Screen.new(40, 8)
|
||||
screen:set_default_attr_ids({
|
||||
[0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
|
||||
[1] = {bold = true, reverse = true}, -- StatusLine
|
||||
[2] = {reverse = true}, -- StatusLineNC
|
||||
})
|
||||
screen:attach()
|
||||
command('set showcmd')
|
||||
command('set showcmdloc=statusline')
|
||||
command('1vsplit')
|
||||
screen:expect([[
|
||||
^ │ |
|
||||
{0:~}│{0:~ }|
|
||||
{0:~}│{0:~ }|
|
||||
{0:~}│{0:~ }|
|
||||
{0:~}│{0:~ }|
|
||||
{0:~}│{0:~ }|
|
||||
{1:< }{2:[No Name] }|
|
||||
|
|
||||
]])
|
||||
feed('1234')
|
||||
screen:expect_unchanged()
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user