Merge pull request #22659 from bfredl/floatruler

fix(screen): redraw the ruler for a current floating window
This commit is contained in:
bfredl 2023-03-14 11:28:48 +01:00 committed by GitHub
commit ef31444ccc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 95 additions and 3 deletions

View File

@ -746,7 +746,7 @@ void show_cursor_info_later(bool force)
|| curwin->w_topfill != curwin->w_stl_topfill
|| empty_line != curwin->w_stl_empty
|| state != curwin->w_stl_state) {
if ((curwin->w_status_height || global_stl_height())) {
if (curwin->w_status_height || global_stl_height()) {
curwin->w_redr_status = true;
} else {
redraw_cmdline = true;

View File

@ -608,7 +608,7 @@ int showmode(void)
// If the last window has no status line and global statusline is disabled,
// the ruler is after the mode message and must be redrawn
win_T *last = lastwin_nofloating();
win_T *last = curwin->w_floating ? curwin : lastwin_nofloating();
if (redrawing() && last->w_status_height == 0 && global_stl_height() == 0) {
win_redr_ruler(last);
}

View File

@ -2184,6 +2184,98 @@ describe('float window', function()
end
end)
it('show ruler of current floating window', function()
command 'set ruler'
local buf = meths.create_buf(false, false)
meths.buf_set_lines(buf, 0, -1, true, {'aaa aab ',
'abb acc '})
meths.open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5})
feed 'gg'
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[3:----------------------------------------]|
## grid 2
|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
1,1 All |
## grid 5
{1:^aaa aab }|
{1:abb acc }|
{2:~ }|
]], float_pos={
[5] = {{id = 1002}, "NW", 1, 0, 5, true, 50};
}, win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
}}
else
screen:expect{grid=[[
{1:^aaa aab } |
{0:~ }{1:abb acc }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }|
{0:~ }|
{0:~ }|
1,1 All |
]]}
end
feed 'w'
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[3:----------------------------------------]|
## grid 2
|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
1,5 All |
## grid 5
{1:aaa ^aab }|
{1:abb acc }|
{2:~ }|
]], float_pos={
[5] = {{id = 1002}, "NW", 1, 0, 5, true, 50};
}, win_viewport={
[2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
[5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 4, linecount = 2, sum_scroll_delta = 0};
}}
else
screen:expect{grid=[[
{1:aaa ^aab } |
{0:~ }{1:abb acc }{0: }|
{0:~ }{2:~ }{0: }|
{0:~ }|
{0:~ }|
{0:~ }|
1,5 All |
]]}
end
end)
it('can have minimum size', function()
insert("the background text")
local buf = meths.create_buf(false, true)

View File

@ -1351,7 +1351,7 @@ local function fmt_ext_state(name, state)
for k,v in pairs(state) do
str = (str.." ["..k.."] = {win = {id = "..v.win.id.."}, topline = "
..v.topline..", botline = "..v.botline..", curline = "..v.curline
..", curcol = "..v.curcol..", linecount = "..v.linecount..", scroll_delta = "..v.scroll_delta.."};\n")
..", curcol = "..v.curcol..", linecount = "..v.linecount..", sum_scroll_delta = "..v.sum_scroll_delta.."};\n")
end
return str .. "}"
elseif name == "float_pos" then