aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/float_spec.lua
diff options
context:
space:
mode:
authorWill Hopkins <willothyh@gmail.com>2024-01-31 19:43:35 -0800
committerGitHub <noreply@github.com>2024-02-01 11:43:35 +0800
commit6bba4becedaea5a330c0c9d9427fb495e8092dac (patch)
tree989ada1e26430843b6b855e8189afc29b2b69267 /test/functional/ui/float_spec.lua
parent8fa67fdae539a13cf78621ab5a628da1fd745be2 (diff)
downloadrneovim-6bba4becedaea5a330c0c9d9427fb495e8092dac.tar.gz
rneovim-6bba4becedaea5a330c0c9d9427fb495e8092dac.tar.bz2
rneovim-6bba4becedaea5a330c0c9d9427fb495e8092dac.zip
feat(api): make nvim_open_win support non-floating windows (#25550)
Adds support to `nvim_open_win` and `nvim_win_set_config` for creating and manipulating split (non-floating) windows.
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r--test/functional/ui/float_spec.lua57
1 files changed, 34 insertions, 23 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index b05e7aceda..397c1f6132 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -104,14 +104,20 @@ describe('float window', function()
end)
it('open with WinNew autocmd', function()
- local res = exec_lua([[
- local triggerd = false
+ local new_triggered_before_enter, new_curwin, win = unpack(exec_lua([[
+ local enter_triggered = false
+ local new_triggered_before_enter = false
+ local new_curwin
local buf = vim.api.nvim_create_buf(true, true)
+ vim.api.nvim_create_autocmd('WinEnter', {
+ callback = function()
+ enter_triggered = true
+ end
+ })
vim.api.nvim_create_autocmd('WinNew', {
- callback = function(opt)
- if opt.buf == buf then
- triggerd = true
- end
+ callback = function()
+ new_triggered_before_enter = not enter_triggered
+ new_curwin = vim.api.nvim_get_current_win()
end
})
local opts = {
@@ -120,10 +126,11 @@ describe('float window', function()
width = 1, height = 1,
noautocmd = false,
}
- vim.api.nvim_open_win(buf, true, opts)
- return triggerd
- ]])
- eq(true, res)
+ local win = vim.api.nvim_open_win(buf, true, opts)
+ return {new_triggered_before_enter, new_curwin, win}
+ ]]))
+ eq(true, new_triggered_before_enter)
+ eq(win, new_curwin)
end)
it('opened with correct height', function()
@@ -1095,7 +1102,7 @@ describe('float window', function()
local expected = {anchor='NW', col=5, external=false, focusable=true, height=2, relative='editor', row=3, width=20, zindex=60, hide=false}
eq(expected, api.nvim_win_get_config(win))
- eq({relative='', external=false, focusable=true, hide=false}, api.nvim_win_get_config(0))
+ eq({external=false, focusable=true, hide=false, relative='',split="left",width=40,height=6}, api.nvim_win_get_config(0))
if multigrid then
api.nvim_win_set_config(win, {external=true, width=10, height=1})
@@ -2878,27 +2885,31 @@ describe('float window', function()
it('API has proper error messages', function()
local buf = api.nvim_create_buf(false,false)
eq("Invalid key: 'bork'",
- pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,bork=true}))
- eq("'win' key is only valid with relative='win'",
- pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,win=0}))
+ pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,bork=true}))
+ eq("'win' key is only valid with relative='win' and relative=''",
+ pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,win=0}))
+ eq("floating windows cannot have 'vertical'",
+ pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,vertical=true}))
+ eq("floating windows cannot have 'split'",
+ pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,split="left"}))
eq("Only one of 'relative' and 'external' must be used",
- pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,external=true}))
+ pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,external=true}))
eq("Invalid value of 'relative' key",
- pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='shell',row=0,col=0}))
+ pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='shell',row=0,col=0}))
eq("Invalid value of 'anchor' key",
- pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,anchor='bottom'}))
+ pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,anchor='bottom'}))
eq("'relative' requires 'row'/'col' or 'bufpos'",
- pcall_err(api.nvim_open_win,buf, false, {width=20,height=2,relative='editor'}))
+ pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor'}))
eq("'width' key must be a positive Integer",
- pcall_err(api.nvim_open_win,buf, false, {width=-1,height=2,relative='editor', row=0, col=0}))
+ pcall_err(api.nvim_open_win, buf, false, {width=-1,height=2,relative='editor', row=0, col=0}))
eq("'height' key must be a positive Integer",
- pcall_err(api.nvim_open_win,buf, false, {width=20,height=-1,relative='editor', row=0, col=0}))
+ pcall_err(api.nvim_open_win, buf, false, {width=20,height=-1,relative='editor', row=0, col=0}))
eq("'height' key must be a positive Integer",
- pcall_err(api.nvim_open_win,buf, false, {width=20,height=0,relative='editor', row=0, col=0}))
+ pcall_err(api.nvim_open_win, buf, false, {width=20,height=0,relative='editor', row=0, col=0}))
eq("Must specify 'width'",
- pcall_err(api.nvim_open_win,buf, false, {relative='editor', row=0, col=0}))
+ pcall_err(api.nvim_open_win, buf, false, {relative='editor', row=0, col=0}))
eq("Must specify 'height'",
- pcall_err(api.nvim_open_win,buf, false, {relative='editor', row=0, col=0, width=2}))
+ pcall_err(api.nvim_open_win, buf, false, {relative='editor', row=0, col=0, width=2}))
end)
it('can be placed relative window or cursor', function()