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.lua165
1 files changed, 165 insertions, 0 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 6c2c4b398a..5f29261b17 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -1,11 +1,13 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
+local global_helpers = require('test.helpers')
local os = require('os')
local clear, feed = helpers.clear, helpers.feed
local assert_alive = helpers.assert_alive
local command, feed_command = helpers.command, helpers.feed_command
local eval = helpers.eval
local eq = helpers.eq
+local neq = helpers.neq
local exec_lua = helpers.exec_lua
local insert = helpers.insert
local meths = helpers.meths
@@ -13,6 +15,7 @@ local curbufmeths = helpers.curbufmeths
local funcs = helpers.funcs
local run = helpers.run
local pcall_err = helpers.pcall_err
+local tbl_contains = global_helpers.tbl_contains
describe('float window', function()
before_each(function()
@@ -294,6 +297,125 @@ describe('float window', function()
eq(12, pos[2])
end)
+ it('is not operated on by windo when non-focusable #15374', function()
+ command([[
+ let winids = []
+ windo call add(winids, win_getid())
+ ]])
+ local windo_count_before = eval('len(winids)')
+ local winid = exec_lua([[
+ local bufnr = vim.api.nvim_create_buf(false, true)
+ local opts = {
+ relative = 'editor',
+ focusable = false,
+ height = 5,
+ width = 5,
+ col = 5,
+ row = 5,
+ }
+ return vim.api.nvim_open_win(bufnr, false, opts)
+ ]])
+ command([[
+ let winids = []
+ windo call add(winids, win_getid())
+ ]])
+ local windo_count_after = eval('len(winids)')
+ eq(windo_count_before, windo_count_after)
+ eq(false, tbl_contains(eval('winids'), winid))
+ end)
+
+ it('is operated on by windo when focusable', function()
+ command([[
+ let winids = []
+ windo call add(winids, win_getid())
+ ]])
+ local windo_count_before = eval('len(winids)')
+ local winid = exec_lua([[
+ local bufnr = vim.api.nvim_create_buf(false, true)
+ local opts = {
+ relative = 'editor',
+ focusable = true,
+ height = 5,
+ width = 5,
+ col = 5,
+ row = 5,
+ }
+ return vim.api.nvim_open_win(bufnr, false, opts)
+ ]])
+ command([[
+ let winids = []
+ windo call add(winids, win_getid())
+ ]])
+ local windo_count_after = eval('len(winids)')
+ eq(windo_count_before + 1, windo_count_after)
+ eq(true, tbl_contains(eval('winids'), winid))
+ end)
+
+ it('is not active after windo when non-focusable #15374', function()
+ local winid = exec_lua([[
+ local bufnr = vim.api.nvim_create_buf(false, true)
+ local opts = {
+ relative = 'editor',
+ focusable = false,
+ height = 5,
+ width = 5,
+ col = 5,
+ row = 5,
+ }
+ return vim.api.nvim_open_win(bufnr, false, opts)
+ ]])
+ command('windo echo')
+ neq(eval('win_getid()'), winid)
+ end)
+
+ it('is active after windo when focusable', function()
+ local winid = exec_lua([[
+ local bufnr = vim.api.nvim_create_buf(false, true)
+ local opts = {
+ relative = 'editor',
+ focusable = true,
+ height = 5,
+ width = 5,
+ col = 5,
+ row = 5,
+ }
+ return vim.api.nvim_open_win(bufnr, false, opts)
+ ]])
+ command('windo echo')
+ eq(eval('win_getid()'), winid)
+ end)
+
+ it('supports windo with focusable and non-focusable floats', function()
+ local winids = exec_lua([[
+ local result = {vim.api.nvim_get_current_win()}
+ local bufnr = vim.api.nvim_create_buf(false, true)
+ local opts = {
+ relative = 'editor',
+ focusable = false,
+ height = 5,
+ width = 5,
+ col = 5,
+ row = 5,
+ }
+ vim.api.nvim_open_win(bufnr, false, opts)
+ opts.focusable = true
+ table.insert(result, vim.api.nvim_open_win(bufnr, false, opts))
+ opts.focusable = false
+ vim.api.nvim_open_win(bufnr, false, opts)
+ opts.focusable = true
+ table.insert(result, vim.api.nvim_open_win(bufnr, false, opts))
+ opts.focusable = false
+ vim.api.nvim_open_win(bufnr, false, opts)
+ return result
+ ]])
+ table.sort(winids)
+ command([[
+ let winids = []
+ windo call add(winids, win_getid())
+ call sort(winids)
+ ]])
+ eq(winids, eval('winids'))
+ end)
local function with_ext_multigrid(multigrid)
local screen
@@ -1194,6 +1316,49 @@ describe('float window', function()
]]}
end
+ meths.win_set_config(win, {border={"", "_", "", "", "", "-", "", ""}})
+ 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 5
+ {5:_________}|
+ {1: halloj! }|
+ {1: BORDAA }|
+ {5:---------}|
+ ]], float_pos={
+ [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
+ }, win_viewport={
+ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1};
+ [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2};
+ }}
+ else
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {0:~ }{5:_________}{0: }|
+ {0:~ }{1: halloj! }{0: }|
+ {0:~ }{1: BORDAA }{0: }|
+ {0:~ }{5:---------}{0: }|
+ |
+ ]]}
+ end
+
insert [[
neeed some dummy
background text