aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/float_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
committerJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
commitd5f194ce780c95821a855aca3c19426576d28ae0 (patch)
treed45f461b19f9118ad2bb1f440a7a08973ad18832 /test/functional/ui/float_spec.lua
parentc5d770d311841ea5230426cc4c868e8db27300a8 (diff)
parent44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff)
downloadrneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.gz
rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.bz2
rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahm
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r--test/functional/ui/float_spec.lua384
1 files changed, 357 insertions, 27 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 57ef9bcff6..15231e0f8c 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -1012,6 +1012,97 @@ describe('float window', function()
end)
end)
+ it('placed relative to tabline and laststatus', function()
+ local screen = Screen.new(20, 10)
+ screen:add_extra_attr_ids({ [100] = { bold = true, foreground = Screen.colors.Magenta } })
+ command('set showtabline=1 laststatus=1')
+ api.nvim_open_win(0, false, {
+ relative = 'laststatus',
+ border = 'single',
+ anchor = 'SE',
+ width = 5,
+ height = 1,
+ row = 0,
+ col = 1000,
+ })
+ local tabwin = api.nvim_open_win(0, false, {
+ relative = 'tabline',
+ border = 'single',
+ width = 5,
+ height = 1,
+ row = 0,
+ col = 1000,
+ })
+ screen:expect([[
+ ^ {2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ {1:~ }|*3
+ {1:~ }{2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ |
+ ]])
+ command('tabnew | tabnext')
+ screen:expect([[
+ {5: }{100:3}{5: Name] }{24: No Name]X}|
+ ^ {2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ {1:~ }|*2
+ {1:~ }{2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ |
+ ]])
+ command('vsplit')
+ screen:expect([[
+ {5: }{100:4}{5: Name] }{24: No Name]X}|
+ ^ {2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ {1:~ }{2:│}{1:~}|
+ {1:~ }{2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ {3:[No Name] }{2:<}|
+ |
+ ]])
+ command('quit')
+ api.nvim_win_set_config(tabwin, {
+ relative = 'tabline',
+ border = 'single',
+ width = 5,
+ height = 1,
+ row = 1,
+ col = 0,
+ })
+ screen:expect([[
+ {5: }{100:3}{5: Name] }{24: No Name]X}|
+ ^ |
+ {2:┌─────┐}{1: }|
+ {2:│}{4: }{2:│}{1: }|
+ {2:└─────┘}{1: }|
+ {1:~ }|
+ {1:~ }{2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ |
+ ]])
+ command('tabonly')
+ screen:expect([[
+ ^ |
+ {2:┌─────┐}{1: }|
+ {2:│}{4: }{2:│}{1: }|
+ {2:└─────┘}{1: }|
+ {1:~ }|*2
+ {1:~ }{2:┌─────┐}|
+ {1:~ }{2:│}{4: }{2:│}|
+ {1:~ }{2:└─────┘}|
+ |
+ ]])
+ end)
+
local function with_ext_multigrid(multigrid)
local screen, attrs
before_each(function()
@@ -1046,6 +1137,8 @@ describe('float window', function()
[26] = {blend = 80, background = Screen.colors.Gray0};
[27] = {foreground = Screen.colors.Black, background = Screen.colors.LightGrey};
[28] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey};
+ [29] = {background = Screen.colors.Yellow1, foreground = Screen.colors.Blue4};
+ [30] = {background = Screen.colors.Grey, foreground = Screen.colors.Blue4, bold = true};
}
screen:set_default_attr_ids(attrs)
end)
@@ -1451,14 +1544,14 @@ describe('float window', function()
[2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
- {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
+ {19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
{19: }{14: 3 }{22: } |
{0:~ }|*3
## grid 3
|
## grid 4
- {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
+ {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
{19: }{15:y }|
{19: }{15: }|
{15: }|
@@ -1466,9 +1559,9 @@ describe('float window', function()
else
screen:expect([[
- {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
+ {19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
- {19: }{14: 3 }{22: } {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
+ {19: }{14: 3 }{22: } {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
{0:~ }{19: }{15:y }{0: }|
{0:~ }{19: }{15: }{0: }|
{0:~ }{15: }{0: }|
@@ -1551,14 +1644,14 @@ describe('float window', function()
[2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
- {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
+ {19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
{19: }{14: 3 }{22: } |
{0:~ }|*3
## grid 3
|
## grid 4
- {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
+ {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
{19: }{15:y }|
{19: }{15: }|
{15: }|
@@ -1566,9 +1659,9 @@ describe('float window', function()
else
screen:expect([[
- {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
+ {19: }{29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
{19: }{14: 2 }{22:y} |
- {19: }{14: 3 }{22: } {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
+ {19: }{14: 3 }{22: } {29:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
{0:~ }{19: }{15:y }{0: }|
{0:~ }{19: }{15: }{0: }|
{0:~ }{15: }{0: }|
@@ -1616,31 +1709,34 @@ describe('float window', function()
feed('ix<cr>y<cr><esc>gg')
api.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'})
if multigrid then
- screen:expect{grid=[[
- ## grid 1
- [2:----------------------------------------]|*6
- [3:----------------------------------------]|
- ## grid 2
- {20: 1}{19: }{22:^x}{21: }|
- {14: 2}{19: }{22:y} |
- {14: 3}{19: }{22: } |
- {0:~ }|*3
- ## grid 3
- |
- ## grid 4
- {15:x }|
- {15:y }|
- {15: }|*2
- ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}}
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ {20: 1}{19: }{22:^x}{21: }|
+ {14: 2}{19: }{22:y} |
+ {14: 3}{19: }{22: } |
+ {0:~ }|*3
+ ## grid 3
+ |
+ ## grid 4
+ {15:x }|
+ {15:y }|
+ {15: }|*2
+ ]],
+ float_pos = { [4] = { 1001, "NW", 1, 4, 10, true, 50 } },
+ })
else
- screen:expect{grid=[[
+ screen:expect([[
{20: 1}{19: }{22:^x}{21: }|
{14: 2}{19: }{22:y} |
{14: 3}{19: }{22: } {15:x } |
{0:~ }{15:y }{0: }|
{0:~ }{15: }{0: }|*2
|
- ]]}
+ ]])
end
end)
@@ -2237,6 +2333,61 @@ describe('float window', function()
|
]]}
end
+
+ -- reuse before title pos
+ api.nvim_win_set_config(win, {title= 'new'})
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|*5
+ ## grid 3
+ |
+ ## grid 4
+ {5:╔══════}{11:new}{5:╗}|
+ {5:║}{1: halloj! }{5:║}|
+ {5:║}{1: BORDAA }{5:║}|
+ {5:╚═════════╝}|
+ ]],
+ float_pos = {
+ [4] = {1001, "NW", 1, 2, 5, true, 50};
+ },
+ win_viewport = {
+ [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
+ },
+ win_viewport_margins = {
+ [2] = {
+ bottom = 0,
+ left = 0,
+ right = 0,
+ top = 0,
+ win = 1000
+ },
+ [4] = {
+ bottom = 1,
+ left = 1,
+ right = 1,
+ top = 1,
+ win = 1001
+ }
+ },
+ })
+ else
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }{5:╔══════}{11:new}{5:╗}{0: }|
+ {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
+ {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
+ {0:~ }{5:╚═════════╝}{0: }|
+ |
+ ]])
+ end
end)
it('border with footer', function()
@@ -2382,6 +2533,61 @@ describe('float window', function()
|
]]}
end
+
+ -- reuse before footer pos
+ api.nvim_win_set_config(win, { footer = 'new' })
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|*5
+ ## grid 3
+ |
+ ## grid 4
+ {5:╔═════════╗}|
+ {5:║}{1: halloj! }{5:║}|
+ {5:║}{1: BORDAA }{5:║}|
+ {5:╚══════}{11:new}{5:╝}|
+ ]],
+ float_pos = {
+ [4] = {1001, "NW", 1, 2, 5, true, 50};
+ },
+ win_viewport = {
+ [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
+ },
+ win_viewport_margins = {
+ [2] = {
+ bottom = 0,
+ left = 0,
+ right = 0,
+ top = 0,
+ win = 1000
+ },
+ [4] = {
+ bottom = 1,
+ left = 1,
+ right = 1,
+ top = 1,
+ win = 1001
+ }
+ },
+ })
+ else
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }{5:╔═════════╗}{0: }|
+ {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
+ {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
+ {0:~ }{5:╚══════}{11:new}{5:╝}{0: }|
+ |
+ ]])
+ end
end)
it('border with title and footer', function()
@@ -8542,6 +8748,131 @@ describe('float window', function()
|
]]}
end
+
+ --
+ -- Check that floats are positioned correctly after changing the zindexes.
+ --
+ command('fclose')
+ exec_lua([[
+ local win1, win3 = ...
+ vim.api.nvim_win_set_config(win1, { zindex = 400, title = 'win_400', title_pos = 'center', border = 'double' })
+ vim.api.nvim_win_set_config(win3, { zindex = 300, title = 'win_300', title_pos = 'center', border = 'single' })
+ ]], win1, win3)
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|*5
+ ## grid 3
+ |
+ ## grid 4
+ {5:╔══════}{11:win_400}{5:═══════╗}|
+ {5:║}{7: }{5:║}|
+ {5:║}{7:~ }{5:║}|*2
+ {5:╚════════════════════╝}|
+ ## grid 6
+ {5:┌──────}{11:win_300}{5:───────┐}|
+ {5:│}{8: }{5:│}|
+ {5:│}{8:~ }{5:│}|*2
+ {5:└────────────────────┘}|
+ ]], float_pos={
+ [4] = {1001, "NW", 1, 1, 5, true, 400};
+ [6] = {1003, "NW", 1, 3, 7, true, 300};
+ }, win_viewport={
+ [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [6] = {win = 1003, 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 },
+ [4] = { bottom = 1, left = 1, right = 1, top = 1, win = 1001 },
+ [6] = { bottom = 1, left = 1, right = 1, top = 1, win = 1003 }
+ }})
+ else
+ screen:expect({
+ grid = [[
+ ^ |
+ {0:~ }{5:╔══════}{11:win_400}{5:═══════╗}{0: }|
+ {0:~ }{5:║}{7: }{5:║─┐}{0: }|
+ {0:~ }{5:║}{7:~ }{5:║}{8: }{5:│}{0: }|*2
+ {0:~ }{5:╚════════════════════╝}{8: }{5:│}{0: }|
+ {5:└────────────────────┘} |
+ ]]
+ })
+ end
+ exec_lua([[
+ local win1, win3 = ...
+ vim.api.nvim_win_set_config(win1, { zindex = 100, title='win_100' })
+ vim.api.nvim_win_set_config(win3, { zindex = 150, title='win_150' })
+ ]], win1, win3)
+ if multigrid then
+ screen:expect({
+ grid = [[
+ ## grid 1
+ [2:----------------------------------------]|*6
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|*5
+ ## grid 3
+ |
+ ## grid 4
+ {5:╔══════}{11:win_100}{5:═══════╗}|
+ {5:║}{7: }{5:║}|
+ {5:║}{7:~ }{5:║}|*2
+ {5:╚════════════════════╝}|
+ ## grid 6
+ {5:┌──────}{11:win_150}{5:───────┐}|
+ {5:│}{8: }{5:│}|
+ {5:│}{8:~ }{5:│}|*2
+ {5:└────────────────────┘}|
+ ]],
+ float_pos = {
+ [4] = {1001, "NW", 1, 1, 5, true, 100};
+ [6] = {1003, "NW", 1, 3, 7, true, 150};
+ },
+ win_viewport = {
+ [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
+ [6] = {win = 1003, 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
+ },
+ [4] = {
+ bottom = 1,
+ left = 1,
+ right = 1,
+ top = 1,
+ win = 1001
+ },
+ [6] = {
+ bottom = 1,
+ left = 1,
+ right = 1,
+ top = 1,
+ win = 1003
+ }
+ },
+ })
+ else
+ screen:expect([[
+ ^ |
+ {0:~ }{5:╔═┌──────}{11:win_150}{5:───────┐}{0: }|
+ {0:~ }{5:║}{7: }{5:│}{8: }{5:│}{0: }|
+ {0:~ }{5:║}{7:~}{5:│}{8:~ }{5:│}{0: }|*2
+ {0:~ }{5:╚═└────────────────────┘}{0: }|
+ |
+ ]])
+ end
end)
it('can use winbar', function()
@@ -9523,4 +9854,3 @@ describe('float window', function()
with_ext_multigrid(false)
end)
end)
-