fix(ui): send multigrid message position and size when the UI is refreshed

This commit is contained in:
Fred Sundvik
2025-02-14 17:26:57 +07:00
parent c5044bd021
commit 424d30fe97
4 changed files with 80 additions and 0 deletions

View File

@ -2521,6 +2521,14 @@ void msg_reset_scroll(void)
msg_grid_scroll_discount = 0;
}
void msg_ui_refresh(void)
{
if (ui_has(kUIMultigrid) && msg_grid.chars) {
ui_call_grid_resize(msg_grid.handle, msg_grid.cols, msg_grid.rows);
ui_ext_msg_set_pos(msg_grid_pos, msg_scrolled);
}
}
/// Increment "msg_scrolled".
static void inc_msg_scrolled(void)
{

View File

@ -229,6 +229,7 @@ void ui_refresh(void)
}
msg_scroll_flush();
}
msg_ui_refresh();
if (!ui_active()) {
return;

View File

@ -2857,4 +2857,71 @@ describe('ext_multigrid', function()
}})
end)
end)
it('message grid is shown at the correct position remote re-attach', function()
feed(':test')
local expected = {
grid = [[
## grid 1
[2:-----------------------------------------------------]|*12
{11:[No Name] }|
[3:-----------------------------------------------------]|
## grid 2
|
{1:~ }|*11
## grid 3
:test^ |
]],
win_pos = {
[2] = {
height = 12,
startcol = 0,
startrow = 0,
width = 53,
win = 1000
}
},
win_viewport = {
[2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
},
win_viewport_margins = {
[2] = {
bottom = 0,
left = 0,
right = 0,
top = 0,
win = 1000
}
},
reset = true
}
screen:expect(expected)
feed('<cr>')
screen:detach()
screen:attach()
feed(':test')
screen:expect(expected)
end)
end)
it('headless attach with showcmd', function()
clear{args={'--headless'}}
local screen = Screen.new(80, 24, {ext_multigrid=true})
command('set showcmd')
feed('1234')
screen:expect({
grid = [[
## grid 1
[2:--------------------------------------------------------------------------------]|*23
[3:--------------------------------------------------------------------------------]|
## grid 2
^ |
{1:~ }|*22
## grid 3
1234 |
]],
win_viewport = {
[2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
},
})
end)

View File

@ -973,6 +973,10 @@ function Screen:_reset()
self.wildmenu_items = nil
self.wildmenu_pos = nil
self._grid_win_extmarks = {}
self.msg_grid = nil
self.msg_grid_pos = nil
self.msg_scrolled = false
self.msg_sep_char = nil
end
--- @param cursor_style_enabled boolean