fix(ruler): show ruler of curwin with no statusline in cmdline

Problem: After neovim/neovim@846a056, only the ruler for current floating or
last window without a statusline is drawn in the cmdline. This means that if the
current window is not one of these, but has no statusline, its ruler will not be
drawn anymore.

Solution: Make `showmode()` draw the ruler of the current window or the last
window in the cmdline if it has no statusline. This also maintains the
previously restored floating window case (`float->w_status_height` should be 0).

This behaviour should again match Vim, but without the overdraw it seems to do
to achieve the same effect; it calls `showmode()` to draw the ruler for the last
window without a statusline, then may draw over it in `showruler()` (which is
now `show_cursor_info_later()` in Nvim) to show the ruler for the current
window..? It's very confusing.

Also update the logic in `win_redr_ruler()` to mirror the check done in
`showmode()`, so that the ruler doesn't potentially draw over the long
ins-completion mode message in some cases.

(cherry picked from commit 65dd3c1180)
This commit is contained in:
Sean Dewar
2023-04-10 21:40:35 +01:00
committed by github-actions[bot]
parent ba198bd7cc
commit 470aa2dbf9
4 changed files with 181 additions and 6 deletions

View File

@@ -653,3 +653,62 @@ it('ruler is redrawn in cmdline with redrawstatus #22804', function()
other value |
]])
end)
it("shows correct ruler in cmdline with no statusline", function()
clear()
local screen = Screen.new(30, 8)
screen:set_default_attr_ids {
[1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
[2] = {bold = true, reverse = true}, -- StatusLine
[3] = {reverse = true}, -- StatusLineNC
}
screen:attach()
-- Use long ruler to check 'ruler' with 'rulerformat' set has correct width.
command [[
set ruler rulerformat=%{winnr()}longlonglong ls=0 winwidth=10
split
wincmd b
vsplit
wincmd t
wincmd |
mode
]]
-- Window 1 is current. It has a statusline, so cmdline should show the
-- last window's ruler, which has no statusline.
command '1wincmd w'
screen:expect [[
^ |
{1:~ }|
{1:~ }|
{2:[No Name] 1longlonglong }|
│ |
{1:~ }│{1:~ }|
{1:~ }│{1:~ }|
3longlonglong |
]]
-- Window 2 is current. It has no statusline, so cmdline should show its
-- ruler instead.
command '2wincmd w'
screen:expect [[
|
{1:~ }|
{1:~ }|
{3:[No Name] 1longlonglong }|
^ │ |
{1:~ }│{1:~ }|
{1:~ }│{1:~ }|
2longlonglong |
]]
-- Window 3 is current. Cmdline should again show its ruler.
command '3wincmd w'
screen:expect [[
|
{1:~ }|
{1:~ }|
{3:[No Name] 1longlonglong }|
│^ |
{1:~ }│{1:~ }|
{1:~ }│{1:~ }|
3longlonglong |
]]
end)