test: screen.lua can check win_pos #32373

Also remove a hack in the multigrid "with winbar" test.
This commit is contained in:
fredizzimo 2025-02-09 22:31:14 +07:00 committed by GitHub
parent 9198368f32
commit af0cd9a907
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 13 deletions

View File

@ -2407,6 +2407,22 @@ describe('ext_multigrid', function()
it('with winbar', function()
command('split')
local win_pos ={
[2] = {
height = 5,
startcol = 0,
startrow = 7,
width = 53,
win = 1000
},
[4] = {
height = 6,
startcol = 0,
startrow = 0,
width = 53,
win = 1001
}
}
screen:expect{grid=[[
## grid 1
[4:-----------------------------------------------------]|*6
@ -2428,15 +2444,7 @@ describe('ext_multigrid', function()
}, win_viewport_margins={
[2] = {win = 1000, top = 0, bottom = 0, left = 0, right = 0};
[4] = {win = 1001, top = 0, bottom = 0, left = 0, right = 0};
}}
-- XXX: hack to get notifications. Could use next_msg() also.
local orig_handle_win_pos = screen._handle_win_pos
local win_pos = {}
function screen._handle_win_pos(self, grid, win, startrow, startcol, width, height)
table.insert(win_pos, {grid, win, startrow, startcol, width, height})
orig_handle_win_pos(self, grid, win, startrow, startcol, width, height)
end
}, win_pos = win_pos }
command('setlocal winbar=very%=bar')
screen:expect{grid=[[
@ -2461,8 +2469,7 @@ describe('ext_multigrid', function()
}, win_viewport_margins={
[2] = {win = 1000, top = 0, bottom = 0, left = 0, right = 0};
[4] = {win = 1001, top = 1, bottom = 0, left = 0, right = 0};
}}
eq({}, win_pos)
}, win_pos = win_pos }
command('setlocal winbar=')
screen:expect{grid=[[
@ -2486,8 +2493,7 @@ describe('ext_multigrid', function()
}, win_viewport_margins={
[2] = {win = 1000, top = 0, bottom = 0, left = 0, right = 0};
[4] = {win = 1001, top = 0, bottom = 0, left = 0, right = 0};
}}
eq({}, win_pos)
}, win_pos = win_pos }
end)
it('with winbar dragging statusline with mouse works correctly', function()

View File

@ -338,6 +338,7 @@ local ext_keys = {
'showmode',
'showcmd',
'ruler',
'win_pos',
'float_pos',
'win_viewport',
'win_viewport_margins',
@ -357,6 +358,7 @@ local expect_keys = {
request_cb = true,
hl_groups = true,
extmarks = true,
win_pos = true,
}
for _, v in ipairs(ext_keys) do
@ -426,6 +428,7 @@ end
--- @field mouse_enabled? boolean
---
--- @field win_viewport? table<integer,table<string,integer>>
--- @field win_pos? table<integer,table<string,integer>>
--- @field float_pos? [integer,integer]
--- @field hl_groups? table<string,integer>
---
@ -628,6 +631,9 @@ screen:redraw_debug() to show all intermediate screen states.]]
if expected.win_viewport_margins == nil then
extstate.win_viewport_margins = nil
end
if expected.win_pos == nil then
extstate.win_pos = nil
end
if expected.float_pos then
expected.float_pos = deepcopy(expected.float_pos)
@ -1520,6 +1526,7 @@ function Screen:_extstate_repr(attr_state)
float_pos = self.float_pos,
win_viewport = win_viewport,
win_viewport_margins = win_viewport_margins,
win_pos = self.win_position,
}
end