aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/float_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r--test/functional/ui/float_spec.lua428
1 files changed, 349 insertions, 79 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 784c2d98f5..bb3255840e 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -29,7 +29,10 @@ describe('floating windows', function()
[10] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta},
[11] = {bold = true, foreground = Screen.colors.Magenta},
[12] = {background = Screen.colors.Red, bold = true, foreground = Screen.colors.Blue1},
- [13] = {background = Screen.colors.WebGray}
+ [13] = {background = Screen.colors.WebGray},
+ [14] = {foreground = Screen.colors.Brown},
+ [15] = {background = Screen.colors.Grey20},
+ [16] = {background = Screen.colors.Grey20, bold = true, foreground = Screen.colors.Blue1},
}
local function with_ext_multigrid(multigrid)
@@ -43,12 +46,10 @@ describe('floating windows', function()
it('can be created and reconfigured', function()
local buf = meths.create_buf(false,false)
local win = meths.open_win(buf, false, 20, 2, {relative='editor', row=2, col=5})
- meths.win_set_option(win , 'winhl', 'Normal:PMenu')
local expected_pos = {
[3]={{id=1001}, 'NW', 1, 2, 5, true},
}
-
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -151,6 +152,83 @@ describe('floating windows', function()
end
end)
+ it('defaults to nonumber and NormalFloat highlight', function()
+ command('set number')
+ command('hi NormalFloat guibg=#333333')
+ feed('ix<cr>y<cr><esc>gg')
+ local win = meths.open_win(0, false, 20, 4, {relative='editor', row=4, col=10})
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ |
+ ## grid 2
+ {14: 1 }^x |
+ {14: 2 }y |
+ {14: 3 } |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ {15:x }|
+ {15:y }|
+ {15: }|
+ {16:~ }|
+ ]], float_pos={[3] = {{id = 1001}, "NW", 1, 4, 10, true}}}
+ else
+ screen:expect([[
+ {14: 1 }^x |
+ {14: 2 }y |
+ {14: 3 } {15:x } |
+ {0:~ }{15:y }{0: }|
+ {0:~ }{15: }{0: }|
+ {0:~ }{16:~ }{0: }|
+ |
+ ]])
+ end
+
+ local buf = meths.create_buf(false, true)
+ meths.win_set_buf(win, buf)
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ {4:[No Name] [+] }|
+ |
+ ## grid 2
+ {14: 1 }^x |
+ {14: 2 }y |
+ {14: 3 } |
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ {15: }|
+ {16:~ }|
+ {16:~ }|
+ {16:~ }|
+ ]], float_pos={[3] = {{id = 1001}, "NW", 1, 4, 10, true}}}
+ else
+ screen:expect([[
+ {14: 1 }^x |
+ {14: 2 }y |
+ {14: 3 } {15: } |
+ {0:~ }{16:~ }{0: }|
+ {0:~ }{16:~ }{0: }|
+ {4:[No Name] }{16:~ }{4: }|
+ |
+ ]])
+ end
+ end)
+
it('API has proper error messages', function()
local buf = meths.create_buf(false,false)
eq({false, "Invalid options key 'bork'"},
@@ -211,7 +289,6 @@ describe('floating windows', function()
local buf = meths.create_buf(false,false)
-- no 'win' arg, relative default window
local win = meths.open_win(buf, false, 20, 2, {relative='win', row=0, col=10})
- meths.win_set_option(win, 'winhl', 'Normal:PMenu')
if multigrid then
screen:expect{grid=[[
## grid 1
@@ -467,8 +544,7 @@ describe('floating windows', function()
screen2:attach(nil, session2)
screen2:set_default_attr_ids(attrs)
local buf = meths.create_buf(false,false)
- local win = meths.open_win(buf, true, 20, 2, {relative='editor', row=2, col=5})
- meths.win_set_option(win, 'winhl', 'Normal:PMenu')
+ meths.open_win(buf, true, 20, 2, {relative='editor', row=2, col=5})
local expected_pos = {
[2]={{id=1001}, 'NW', 1, 2, 5}
}
@@ -502,9 +578,8 @@ describe('floating windows', function()
local buf = meths.create_buf(false,false)
meths.buf_set_lines(buf, 0, -1, true, {'such', 'very', 'float'})
local win = meths.open_win(buf, false, 15, 4, {relative='editor', row=2, col=10})
- meths.win_set_option(win , 'winhl', 'Normal:PMenu')
local expected_pos = {
- [3]={{id=1001}, 'NW', 1, 2, 10, true},
+ [4]={{id=1002}, 'NW', 1, 2, 10, true},
}
if multigrid then
screen:expect{grid=[[
@@ -523,7 +598,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:such }|
{1:very }|
{1:float }|
@@ -555,7 +630,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:such }|
{1:very }|
{1:float }|
@@ -583,7 +658,7 @@ describe('floating windows', function()
^ |
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:such }|
{1:very }|
{1:float }|
@@ -608,7 +683,7 @@ describe('floating windows', function()
## grid 2
^ |
{0:~ }|
- ## grid 3
+ ## grid 4
{1:such }|
{1:very }|
{1:float }|
@@ -631,7 +706,7 @@ describe('floating windows', function()
## grid 2
|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:such }|
{1:very }|
{1:^float }|
@@ -663,7 +738,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:such }|
{1:very }|
{1:^float }|
@@ -700,7 +775,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:^such }|
{1:very }|
{1:float }|
@@ -735,7 +810,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:^such }|
{1:very }|
{1:float }|
@@ -770,7 +845,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:^such }|
{1:very }|
{1:float }|
@@ -805,7 +880,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:^such }|
{1:very }|
{1:float }|
@@ -840,7 +915,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:^such }|
{1:very }|
{1:float }|
@@ -875,7 +950,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:^such }|
{1:very }|
{1:float }|
@@ -910,7 +985,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:^such }|
{1:very }|
{1:float }|
@@ -945,7 +1020,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:^such }|
{1:very }|
{1:float }|
@@ -971,7 +1046,7 @@ describe('floating windows', function()
|
## grid 2
|
- ## grid 3
+ ## grid 4
{1:^such }|
{1:very }|
{1:float }|
@@ -1001,7 +1076,7 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
{0:~ }|
- ## grid 3
+ ## grid 4
{1:^such }|
{1:very }|
{1:float }|
@@ -1019,6 +1094,13 @@ describe('floating windows', function()
end
end)
+ it('does not crash when set cmdheight #9680', function()
+ local buf = meths.create_buf(false,false)
+ meths.open_win(buf, false, 20, 2, {relative='editor', row=2, col=5})
+ command("set cmdheight=2")
+ eq(1, meths.eval('1'))
+ end)
+
describe('and completion', function()
before_each(function()
local buf = meths.create_buf(false,false)
@@ -1395,9 +1477,233 @@ describe('floating windows', function()
]])
end
end)
-
end)
+ describe('float shown after pum', function()
+ local win
+ before_each(function()
+ command('hi NormalFloat guibg=#333333')
+ feed('i')
+ funcs.complete(1, {'aa', 'word', 'longtext'})
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ {3:-- INSERT --} |
+ ## grid 2
+ aa^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ {13:aa }|
+ {1:word }|
+ {1:longtext }|
+ ]], float_pos={
+ [3] = {{id = -1}, "NW", 2, 1, 0, false}}
+ }
+ else
+ screen:expect([[
+ aa^ |
+ {13:aa }{0: }|
+ {1:word }{0: }|
+ {1:longtext }{0: }|
+ {0:~ }|
+ {0:~ }|
+ {3:-- INSERT --} |
+ ]])
+ end
+
+ local buf = meths.create_buf(false,true)
+ meths.buf_set_lines(buf,0,-1,true,{"some info", "about item"})
+ win = meths.open_win(buf, false, 12, 2, {relative='cursor', row=1, col=10})
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ {3:-- INSERT --} |
+ ## grid 2
+ aa^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ {13:aa }|
+ {1:word }|
+ {1:longtext }|
+ ## grid 5
+ {15:some info }|
+ {15:about item }|
+ ]], float_pos={
+ [3] = {{id = -1}, "NW", 2, 1, 0, false},
+ [5] = {{id = 1002}, "NW", 2, 1, 12, true},
+ }}
+ else
+ screen:expect([[
+ aa^ |
+ {13:aa }{15:e info }{0: }|
+ {1:word }{15:ut item }{0: }|
+ {1:longtext }{0: }|
+ {0:~ }|
+ {0:~ }|
+ {3:-- INSERT --} |
+ ]])
+ end
+ end)
+
+ it('and close pum first', function()
+ feed('<c-y>')
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ {3:-- INSERT --} |
+ ## grid 2
+ aa^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 5
+ {15:some info }|
+ {15:about item }|
+ ]], float_pos={
+ [5] = {{id = 1002}, "NW", 2, 1, 12, true},
+ }}
+ else
+ screen:expect([[
+ aa^ |
+ {0:~ }{15:some info }{0: }|
+ {0:~ }{15:about item }{0: }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {3:-- INSERT --} |
+ ]])
+ end
+
+ meths.win_close(win, false)
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ {3:-- INSERT --} |
+ ## grid 2
+ aa^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ]])
+ else
+ screen:expect([[
+ aa^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {3:-- INSERT --} |
+ ]])
+ end
+ end)
+
+ it('and close float first', function()
+ meths.win_close(win, false)
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ {3:-- INSERT --} |
+ ## grid 2
+ aa^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ {13:aa }|
+ {1:word }|
+ {1:longtext }|
+ ]], float_pos={
+ [3] = {{id = -1}, "NW", 2, 1, 0, false},
+ }}
+ else
+ screen:expect([[
+ aa^ |
+ {13:aa }{0: }|
+ {1:word }{0: }|
+ {1:longtext }{0: }|
+ {0:~ }|
+ {0:~ }|
+ {3:-- INSERT --} |
+ ]])
+ end
+
+ feed('<c-y>')
+ if multigrid then
+ screen:expect([[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ {3:-- INSERT --} |
+ ## grid 2
+ aa^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ]])
+ else
+ screen:expect([[
+ aa^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {3:-- INSERT --} |
+ ]])
+ end
+ end)
+ end)
describe("handles :wincmd", function()
local win
@@ -1410,7 +1716,6 @@ describe('floating windows', function()
local buf = meths.create_buf(false,false)
win = meths.open_win(buf, false, 20, 2, {relative='editor', row=2, col=5})
meths.buf_set_lines(buf,0,-1,true,{"y"})
- meths.win_set_option(win , 'winhl', 'Normal:PMenu')
expected_pos = {
[3]={{id=1001}, 'NW', 1, 2, 5, true}
}
@@ -2067,39 +2372,6 @@ describe('floating windows', function()
{1:y }|
{2:~ }|
## grid 4
- {1:^y }|
- {2:~ }|
- ]], float_pos=expected_pos}
- else
- screen:expect([[
- {1:^y }|
- {2:~ }|
- {4:[No N}{1:y }{4: }|
- x {2:~ } |
- {0:~ }|
- {5:[No Name] [+] }|
- |
- ]])
- end
-
- feed(":set winhighlight=<cr><c-l>")
- if multigrid then
- screen:expect{grid=[[
- ## grid 1
- [4:----------------------------------------]|
- [4:----------------------------------------]|
- {4:[No Name] [+] }|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- {5:[No Name] [+] }|
- |
- ## grid 2
- x |
- {0:~ }|
- ## grid 3
- {1:y }|
- {2:~ }|
- ## grid 4
^y |
{0:~ }|
]], float_pos=expected_pos}
@@ -2115,7 +2387,6 @@ describe('floating windows', function()
]])
end
-
feed("<c-w>j")
if multigrid then
screen:expect{grid=[[
@@ -2652,16 +2923,16 @@ describe('floating windows', function()
x |
{0:~ }|
## grid 3
- {1:^y }|
- {2:~ }|
+ ^y |
+ {0:~ }|
]]}
else
screen:expect([[
x |
{0:~ }|
{5:[No Name] [+] }|
- {1:^y }|
- {2:~ }|
+ ^y |
+ {0:~ }|
{4:[No Name] [+] }|
|
]])
@@ -2686,8 +2957,8 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
## grid 3
- {1:^y }|
- {2:~ }|
+ ^y |
+ {0:~ }|
]], float_pos=expected_pos}
else
eq({false, "UI doesn't support external windows"},
@@ -2710,11 +2981,10 @@ describe('floating windows', function()
x |
{0:~ }|
## grid 3
- {1:^y }|
- {2:~ }|
+ ^y |
+ {0:~ }|
]])
end
-
end)
it('movements with nested split layout', function()
@@ -2779,8 +3049,8 @@ describe('floating windows', function()
4 |
{0:~ }|
## grid 3
- ^5 |
- {0:~ }|
+ {1:^5 }|
+ {2:~ }|
## grid 4
2 |
{0:~ }|
@@ -2795,8 +3065,8 @@ describe('floating windows', function()
screen:expect([[
1 {5:│}2 |
{0:~ }{5:│}{0:~ }|
- {5:[No N}^5 {5:ame] [+] }|
- 3 {0:~ } |
+ {5:[No N}{1:^5 }{5:ame] [+] }|
+ 3 {2:~ } |
{0:~ }{5:│}{0:~ }|
{5:[No Name] [+] [No Name] [+] }|
:enew |
@@ -2978,8 +3248,8 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
## grid 3
- {1:y }|
- {2:~ }|
+ y |
+ {0:~ }|
## grid 4
^ |
{0:~ }|
@@ -3009,8 +3279,8 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
## grid 3
- {1:y }|
- {2:~ }|
+ y |
+ {0:~ }|
## grid 4
|
{0:~ }|
@@ -3037,8 +3307,8 @@ describe('floating windows', function()
{0:~ }|
{0:~ }|
## grid 3
- {1:y }|
- {2:~ }|
+ y |
+ {0:~ }|
## grid 4
^ |
{0:~ }|