diff options
author | andrew-pa <andrew.pa@outlook.com> | 2021-06-10 20:07:52 -0700 |
---|---|---|
committer | andrew-pa <andrew.pa@outlook.com> | 2021-09-08 10:31:47 -0600 |
commit | 9065730680d1a52f7487ff555bdb1f5b11904c88 (patch) | |
tree | a95c9d86f9e0523e72ac0c2089d686ddcdb0d655 /test/functional/ui/float_spec.lua | |
parent | 1df8a34a7b91028413d6ac751b9dbf9fdcd6cda2 (diff) | |
download | rneovim-9065730680d1a52f7487ff555bdb1f5b11904c88.tar.gz rneovim-9065730680d1a52f7487ff555bdb1f5b11904c88.tar.bz2 rneovim-9065730680d1a52f7487ff555bdb1f5b11904c88.zip |
fix(windowing): positioning of relative floats
Fix relative floating windows so that they open in the correct position
relative to each other. Also make sure that their positions are correct
immediately after creation without a redraw.
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r-- | test/functional/ui/float_spec.lua | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index f3b840da21..16feb3e56b 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -152,6 +152,132 @@ describe('float window', function() eq(10, width) end) + it('opened with correct position', function() + local pos = exec_lua([[ + local bufnr = vim.api.nvim_create_buf(false, true) + + local opts = { + width = 10, + height = 10, + col = 7, + row = 9, + relative = 'editor', + style = 'minimal' + } + + local win_id = vim.api.nvim_open_win(bufnr, false, opts) + + return vim.api.nvim_win_get_position(win_id) + ]]) + + eq(9, pos[1]) + eq(7, pos[2]) + end) + + it('opened with correct position relative to the cursor', function() + local pos = exec_lua([[ + local bufnr = vim.api.nvim_create_buf(false, true) + + local opts = { + width = 10, + height = 10, + col = 7, + row = 9, + relative = 'cursor', + style = 'minimal' + } + + local win_id = vim.api.nvim_open_win(bufnr, false, opts) + + return vim.api.nvim_win_get_position(win_id) + ]]) + + eq(9, pos[1]) + eq(7, pos[2]) + end) + + it('opened with correct position relative to another window', function() + local pos = exec_lua([[ + local bufnr = vim.api.nvim_create_buf(false, true) + + local par_opts = { + width = 50, + height = 50, + col = 7, + row = 9, + relative = 'editor', + style = 'minimal' + } + + local par_win_id = vim.api.nvim_open_win(bufnr, false, par_opts) + + local opts = { + width = 10, + height = 10, + col = 7, + row = 9, + relative = 'win', + style = 'minimal', + win = par_win_id + } + + local win_id = vim.api.nvim_open_win(bufnr, false, opts) + + return vim.api.nvim_win_get_position(win_id) + ]]) + + eq(18, pos[1]) + eq(14, pos[2]) + end) + + + it('opened with correct position relative to another relative window', function() + local pos = exec_lua([[ + local bufnr = vim.api.nvim_create_buf(false, true) + + local root_opts = { + width = 50, + height = 50, + col = 7, + row = 9, + relative = 'editor', + style = 'minimal' + } + + local root_win_id = vim.api.nvim_open_win(bufnr, false, root_opts) + + local par_opts = { + width = 20, + height = 20, + col = 2, + row = 3, + relative = 'win', + win = root_win_id, + style = 'minimal' + } + + local par_win_id = vim.api.nvim_open_win(bufnr, false, par_opts) + + local opts = { + width = 10, + height = 10, + col = 3, + row = 2, + relative = 'win', + win = par_win_id, + style = 'minimal' + } + + local win_id = vim.api.nvim_open_win(bufnr, false, opts) + + return vim.api.nvim_win_get_position(win_id) + ]]) + + eq(14, pos[1]) + eq(12, pos[2]) + end) + + local function with_ext_multigrid(multigrid) local screen before_each(function() |