mirror of
https://github.com/neovim/neovim.git
synced 2026-08-27 01:21:48 +00:00
fix(ruler): always clear ruler when disabled
Problem: the ruler is not cleared in the following circumstances: - ui1 is running - 'rulerformat' is configured - the default ruler was not previously visible in the last line, for example because 'rulerformat' is configured in init.lua - 'ruler' is disabled without using the command-line, for example via key-binding (entering the command-line would clear the ruler) The corresponding test case did not fail because 'rulerformat' was set while the default ruler was shown. Solution: use a dedicated variable for tracking whether the ui1 ruler was previously shown in the last line. `did_ruler_col` is now only used for setting `msg_col`, which is not implemented in the case where 'rulerformat' is configured. Reorder the test code to make the individual checks more independent from each other, and to reflect the future where 'rulerformat' will never be empty. Note that the check where 'rulerformat' was configured relied on the default ruler not being cleared and a stale "0," still being shown in front of the new ruler - this is also fixed with ui2.
This commit is contained in:
@@ -482,6 +482,7 @@ void win_redr_winbar(win_T *wp)
|
||||
|
||||
void redraw_ruler(void)
|
||||
{
|
||||
static bool did_show_ruler = false;
|
||||
static int did_ruler_col = -1;
|
||||
win_T *wp = !curwin->w_config.hide
|
||||
&& curwin->w_status_height == 0 ? curwin : lastwin_nofloating(NULL);
|
||||
@@ -495,8 +496,11 @@ void redraw_ruler(void)
|
||||
} else if (did_ruler_col > 0) {
|
||||
msg_col = did_ruler_col;
|
||||
msg_row = Rows - 1;
|
||||
}
|
||||
if (did_show_ruler && !ui_has(kUIMessages)) {
|
||||
msg_clr_eos();
|
||||
}
|
||||
did_show_ruler = false;
|
||||
did_ruler_col = -1;
|
||||
return;
|
||||
}
|
||||
@@ -516,6 +520,7 @@ void redraw_ruler(void)
|
||||
bool part_of_status = wp->w_status_height || is_stl_global;
|
||||
if (*p_ruf && (p_ch > 0 || (ui_has(kUIMessages) && !part_of_status))) {
|
||||
win_redr_stl_expr(wp, false, true, ui_has(kUIMessages));
|
||||
did_show_ruler = !ui_has(kUIMessages);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -605,6 +610,7 @@ void redraw_ruler(void)
|
||||
}
|
||||
|
||||
grid_line_start(&msg_grid_adj, Rows - 1);
|
||||
did_show_ruler = true;
|
||||
did_ruler_col = off + this_ru_col;
|
||||
int w = grid_line_puts(did_ruler_col, buffer, -1, attr);
|
||||
grid_line_fill(did_ruler_col + w, off + width, fillchar, attr);
|
||||
|
||||
@@ -1890,7 +1890,22 @@ describe('ui/builtin messages', function()
|
||||
end)
|
||||
|
||||
it('supports ruler with laststatus=0', function()
|
||||
command('set ruler laststatus=0')
|
||||
command('set laststatus=0 ruler rulerformat=%-15(%c%V\\ %p%%%)')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|*5
|
||||
0-1 100% |
|
||||
]])
|
||||
|
||||
-- Ruler is cleared when it is no longer drawn.
|
||||
command('set noruler')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|*5
|
||||
|
|
||||
]])
|
||||
|
||||
command('set ruler rulerformat&')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|*5
|
||||
@@ -1903,21 +1918,6 @@ describe('ui/builtin messages', function()
|
||||
{1:~ }|*5
|
||||
{101: 0,0-1 All }|
|
||||
]])
|
||||
|
||||
command('set rulerformat=%15(%c%V\\ %p%%%)')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|*5
|
||||
{101: 0,0-1 100% }|
|
||||
]])
|
||||
|
||||
-- Ruler is cleared when it is no longer drawn.
|
||||
command('set noruler')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|*5
|
||||
{101: }|
|
||||
]])
|
||||
end)
|
||||
|
||||
it('supports echo with CRLF line separators', function()
|
||||
|
||||
Reference in New Issue
Block a user