fix(float): make "fixed" work with relative=win (#25243)

This commit is contained in:
zeertzjq
2023-09-19 18:45:11 +08:00
committed by GitHub
parent 1db45a9c1f
commit c5abf487f1
2 changed files with 42 additions and 62 deletions

View File

@@ -940,85 +940,67 @@ describe('float window', function()
end)
it('window position fixed', function()
command('rightbelow 20vsplit')
local buf = meths.create_buf(false,false)
command("set nowrap")
local win = meths.open_win(buf, false, {
relative='editor', width=20, height=2, row=2, col=30, anchor = 'NW', fixed = true})
local expected_pos = {
[4]={{id=1001}, 'NW', 1, 2, 30, true},
}
relative='win', width=15, height=2, row=2, col=10, anchor='NW', fixed=true})
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:-------------------]{5:│}[4:--------------------]|
[2:-------------------]{5:│}[4:--------------------]|
[2:-------------------]{5:│}[4:--------------------]|
[2:-------------------]{5:│}[4:--------------------]|
[2:-------------------]{5:│}[4:--------------------]|
{5:[No Name] }{4:[No Name] }|
[3:----------------------------------------]|
## grid 2
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
|
## grid 4
{1: }|
{2:~ }|
]], float_pos=expected_pos}
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 5
{1: }|
{2:~ }|
]], float_pos={
[5] = {{id = 1002}, "NW", 4, 2, 10, true, 50};
}}
else
screen:expect([[
^ |
{0:~ }|
{0:~ }{1: }|
{0:~ }{2:~ }|
{0:~ }|
{0:~ }|
{5:│}^ |
{0:~ }{5:│}{0:~ }|
{0:~ }{5:│}{0:~ }{1: }|
{0:~ }{5:│}{0:~ }{2:~ }|
{0:~ }{5:│}{0:~ }|
{5:[No Name] }{4:[No Name] }|
|
]])
]])
end
meths.win_set_config(win, {
relative='editor', width=20, height=2, row=2, col=30, anchor = 'NW', fixed = false})
meths.win_set_config(win, {fixed=false})
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[3:----------------------------------------]|
## grid 2
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
|
## grid 4
{1: }|
{2:~ }|
]], float_pos=expected_pos}
screen:expect_unchanged()
else
screen:expect([[
^ |
{0:~ }|
{0:~ }{1: }|
{0:~ }{2:~ }|
{0:~ }|
{0:~ }|
{5:│}^ |
{0:~ }{5:│}{0:~ }|
{0:~ }{5:│}{0:~ }{1: }|
{0:~ }{5:│}{0:~ }{2:~ }|
{0:~ }{5:│}{0:~ }|
{5:[No Name] }{4:[No Name] }|
|
]])
]])
end
end)