aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/float_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-03-09 14:57:57 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-03-09 14:57:57 -0700
commitc324271b99eee4c621463f368914d57cd729bd9c (patch)
tree5d979d333a2d5f9c080991d5482fd5916f8579c6 /test/functional/ui/float_spec.lua
parent931bffbda3668ddc609fc1da8f9eb576b170aa52 (diff)
parentade1b12f49c3b3914c74847d791eb90ea90b56b7 (diff)
downloadrneovim-c324271b99eee4c621463f368914d57cd729bd9c.tar.gz
rneovim-c324271b99eee4c621463f368914d57cd729bd9c.tar.bz2
rneovim-c324271b99eee4c621463f368914d57cd729bd9c.zip
Merge remote-tracking branch 'upstream/master' into userreg
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r--test/functional/ui/float_spec.lua5239
1 files changed, 1524 insertions, 3715 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 2902b4a4a5..cdb3b79963 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -1,6 +1,5 @@
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
@@ -12,14 +11,15 @@ local expect = helpers.expect
local exec = helpers.exec
local exec_lua = helpers.exec_lua
local insert = helpers.insert
-local meths = helpers.meths
-local curbufmeths = helpers.curbufmeths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local run = helpers.run
local pcall_err = helpers.pcall_err
-local tbl_contains = global_helpers.tbl_contains
-local curbuf, curwin, curtab = helpers.curbuf, helpers.curwin, helpers.curtab
-local NIL = helpers.NIL
+local tbl_contains = vim.tbl_contains
+local curbuf = helpers.api.nvim_get_current_buf
+local curwin = helpers.api.nvim_get_current_win
+local curtab = helpers.api.nvim_get_current_tabpage
+local NIL = vim.NIL
describe('float window', function()
before_each(function()
@@ -31,36 +31,36 @@ describe('float window', function()
-- Create three windows and test that ":wincmd <direction>" changes to the
-- first window, if the previous window is invalid.
command('split')
- meths.open_win(0, true, {width=10, height=10, relative='editor', row=0, col=0})
- eq(1002, funcs.win_getid())
- eq('editor', meths.win_get_config(1002).relative)
+ api.nvim_open_win(0, true, {width=10, height=10, relative='editor', row=0, col=0})
+ eq(1002, fn.win_getid())
+ eq('editor', api.nvim_win_get_config(1002).relative)
command([[
call nvim_win_close(1001, v:false)
wincmd j
]])
- eq(1000, funcs.win_getid())
+ eq(1000, fn.win_getid())
end)
it('win_execute() should work' , function()
- local buf = meths.create_buf(false, false)
- meths.buf_set_lines(buf, 0, -1, true, {'the floatwin', 'abc', 'def'})
- local win = meths.open_win(buf, false, {relative='win', width=16, height=1, row=0, col=10})
- local line = funcs.win_execute(win, 'echo getline(1)')
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'the floatwin', 'abc', 'def'})
+ local win = api.nvim_open_win(buf, false, {relative='win', width=16, height=1, row=0, col=10})
+ local line = fn.win_execute(win, 'echo getline(1)')
eq('\nthe floatwin', line)
- eq('\n1', funcs.win_execute(win, 'echo line(".",'..win.id..')'))
- eq('\n3', funcs.win_execute(win, 'echo line("$",'..win.id..')'))
- eq('\n0', funcs.win_execute(win, 'echo line("$", 123456)'))
- funcs.win_execute(win, 'bwipe!')
+ eq('\n1', fn.win_execute(win, 'echo line(".",'..win..')'))
+ eq('\n3', fn.win_execute(win, 'echo line("$",'..win..')'))
+ eq('\n0', fn.win_execute(win, 'echo line("$", 123456)'))
+ fn.win_execute(win, 'bwipe!')
end)
it("win_execute() call commands that are not allowed when 'hidden' is not set" , function()
command('set nohidden')
- local buf = meths.create_buf(false, false)
- meths.buf_set_lines(buf, 0, -1, true, {'the floatwin'})
- local win = meths.open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10})
- eq('Vim(close):E37: No write since last change (add ! to override)', pcall_err(funcs.win_execute, win, 'close'))
- eq('Vim(bdelete):E89: No write since last change for buffer 2 (add ! to override)', pcall_err(funcs.win_execute, win, 'bdelete'))
- funcs.win_execute(win, 'bwipe!')
+ local buf = api.nvim_create_buf(false, false)
+ api.nvim_buf_set_lines(buf, 0, -1, true, {'the floatwin'})
+ local win = api.nvim_open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10})
+ eq('Vim(close):E37: No write since last change (add ! to override)', pcall_err(fn.win_execute, win, 'close'))
+ eq('Vim(bdelete):E89: No write since last change for buffer 2 (add ! to override)', pcall_err(fn.win_execute, win, 'bdelete'))
+ fn.win_execute(win, 'bwipe!')
end)
it('closed immediately by autocmd #11383', function()
@@ -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()
@@ -193,7 +200,7 @@ describe('float window', function()
end)
it('opened with correct position relative to the mouse', function()
- meths.input_mouse('left', 'press', '', 0, 10, 10)
+ api.nvim_input_mouse('left', 'press', '', 0, 10, 10)
local pos = exec_lua([[
local bufnr = vim.api.nvim_create_buf(false, true)
@@ -480,67 +487,67 @@ describe('float window', function()
it('no crash with bufpos and non-existent window', function()
command('new')
- local closed_win = meths.get_current_win().id
+ local closed_win = api.nvim_get_current_win()
command('close')
- local buf = meths.create_buf(false,false)
- meths.open_win(buf, true, {relative='win', win=closed_win, width=1, height=1, bufpos={0,0}})
+ local buf = api.nvim_create_buf(false,false)
+ api.nvim_open_win(buf, true, {relative='win', win=closed_win, width=1, height=1, bufpos={0,0}})
assert_alive()
end)
it("no segfault when setting minimal style after clearing local 'fillchars' #19510", function()
local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
- local float_win = meths.open_win(0, true, float_opts)
- meths.set_option_value('fillchars', NIL, {win=float_win.id})
+ local float_win = api.nvim_open_win(0, true, float_opts)
+ api.nvim_set_option_value('fillchars', NIL, {win=float_win})
float_opts.style = 'minimal'
- meths.win_set_config(float_win, float_opts)
+ api.nvim_win_set_config(float_win, float_opts)
assert_alive()
end)
it("should re-apply 'style' when present", function()
local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1}
- local float_win = meths.open_win(0, true, float_opts)
- meths.set_option_value('number', true, { win = float_win })
+ local float_win = api.nvim_open_win(0, true, float_opts)
+ api.nvim_set_option_value('number', true, { win = float_win })
float_opts.row = 2
- meths.win_set_config(float_win, float_opts)
- eq(false, meths.get_option_value('number', { win = float_win }))
+ api.nvim_win_set_config(float_win, float_opts)
+ eq(false, api.nvim_get_option_value('number', { win = float_win }))
end)
it("should not re-apply 'style' when missing", function()
local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1}
- local float_win = meths.open_win(0, true, float_opts)
- meths.set_option_value('number', true, { win = float_win })
+ local float_win = api.nvim_open_win(0, true, float_opts)
+ api.nvim_set_option_value('number', true, { win = float_win })
float_opts.row = 2
float_opts.style = nil
- meths.win_set_config(float_win, float_opts)
- eq(true, meths.get_option_value('number', { win = float_win }))
+ api.nvim_win_set_config(float_win, float_opts)
+ eq(true, api.nvim_get_option_value('number', { win = float_win }))
end)
it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function()
- meths.set_option_value('splitkeep', 'screen', {})
+ api.nvim_set_option_value('splitkeep', 'screen', {})
local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10}
- local float_win = meths.open_win(0, true, float_opts)
- eq(5, meths.get_option_value('scroll', {win=float_win.id}))
+ local float_win = api.nvim_open_win(0, true, float_opts)
+ eq(5, api.nvim_get_option_value('scroll', {win=float_win}))
end)
it(':unhide works when there are floating windows', function()
local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5}
local w0 = curwin()
- meths.open_win(0, false, float_opts)
- meths.open_win(0, false, float_opts)
- eq(3, #meths.list_wins())
+ api.nvim_open_win(0, false, float_opts)
+ api.nvim_open_win(0, false, float_opts)
+ eq(3, #api.nvim_list_wins())
command('unhide')
- eq({ w0 }, meths.list_wins())
+ eq({ w0 }, api.nvim_list_wins())
end)
it(':all works when there are floating windows', function()
command('args Xa.txt')
local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5}
local w0 = curwin()
- meths.open_win(0, false, float_opts)
- meths.open_win(0, false, float_opts)
- eq(3, #meths.list_wins())
+ api.nvim_open_win(0, false, float_opts)
+ api.nvim_open_win(0, false, float_opts)
+ eq(3, #api.nvim_list_wins())
command('all')
- eq({ w0 }, meths.list_wins())
+ eq({ w0 }, api.nvim_list_wins())
end)
describe('with only one tabpage,', function()
@@ -548,42 +555,42 @@ describe('float window', function()
local old_buf, old_win
before_each(function()
insert('foo')
- old_buf = curbuf().id
- old_win = curwin().id
+ old_buf = curbuf()
+ old_win = curwin()
end)
describe('closing the last non-floating window gives E444', function()
before_each(function()
- meths.open_win(old_buf, true, float_opts)
+ api.nvim_open_win(old_buf, true, float_opts)
end)
it('if called from non-floating window', function()
- meths.set_current_win(old_win)
+ api.nvim_set_current_win(old_win)
eq('Vim:E444: Cannot close last window',
- pcall_err(meths.win_close, old_win, false))
+ pcall_err(api.nvim_win_close, old_win, false))
end)
it('if called from floating window', function()
eq('Vim:E444: Cannot close last window',
- pcall_err(meths.win_close, old_win, false))
+ pcall_err(api.nvim_win_close, old_win, false))
end)
end)
describe("deleting the last non-floating window's buffer", function()
describe('leaves one window with an empty buffer when there is only one buffer', function()
local same_buf_float
before_each(function()
- same_buf_float = meths.open_win(old_buf, false, float_opts).id
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts)
end)
after_each(function()
- eq(old_win, curwin().id)
+ eq(old_win, curwin())
expect('')
- eq(1, #meths.list_wins())
+ eq(1, #api.nvim_list_wins())
end)
it('if called from non-floating window', function()
- meths.buf_delete(old_buf, {force = true})
+ api.nvim_buf_delete(old_buf, {force = true})
end)
it('if called from floating window', function()
- meths.set_current_win(same_buf_float)
+ api.nvim_set_current_win(same_buf_float)
command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')
command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')
- meths.buf_delete(old_buf, {force = true})
+ api.nvim_buf_delete(old_buf, {force = true})
eq(same_buf_float, eval('g:win_leave'))
eq(old_win, eval('g:win_enter'))
end)
@@ -591,67 +598,67 @@ describe('float window', function()
describe('closes other windows with that buffer when there are other buffers', function()
local same_buf_float, other_buf, other_buf_float
before_each(function()
- same_buf_float = meths.open_win(old_buf, false, float_opts).id
- other_buf = meths.create_buf(true, false).id
- other_buf_float = meths.open_win(other_buf, true, float_opts).id
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts)
+ other_buf = api.nvim_create_buf(true, false)
+ other_buf_float = api.nvim_open_win(other_buf, true, float_opts)
insert('bar')
- meths.set_current_win(old_win)
+ api.nvim_set_current_win(old_win)
end)
after_each(function()
- eq(other_buf, curbuf().id)
+ eq(other_buf, curbuf())
expect('bar')
- eq(2, #meths.list_wins())
+ eq(2, #api.nvim_list_wins())
end)
it('if called from non-floating window', function()
- meths.buf_delete(old_buf, {force = true})
- eq(old_win, curwin().id)
+ api.nvim_buf_delete(old_buf, {force = true})
+ eq(old_win, curwin())
end)
it('if called from floating window with the same buffer', function()
- meths.set_current_win(same_buf_float)
+ api.nvim_set_current_win(same_buf_float)
command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')
command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')
- meths.buf_delete(old_buf, {force = true})
+ api.nvim_buf_delete(old_buf, {force = true})
eq(same_buf_float, eval('g:win_leave'))
eq(old_win, eval('g:win_enter'))
- eq(old_win, curwin().id)
+ eq(old_win, curwin())
end)
-- TODO: this case is too hard to deal with
pending('if called from floating window with another buffer', function()
- meths.set_current_win(other_buf_float)
- meths.buf_delete(old_buf, {force = true})
+ api.nvim_set_current_win(other_buf_float)
+ api.nvim_buf_delete(old_buf, {force = true})
end)
end)
describe('creates an empty buffer when there is only one listed buffer', function()
local same_buf_float, unlisted_buf_float
before_each(function()
- same_buf_float = meths.open_win(old_buf, false, float_opts).id
- local unlisted_buf = meths.create_buf(true, false).id
- unlisted_buf_float = meths.open_win(unlisted_buf, true, float_opts).id
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts)
+ local unlisted_buf = api.nvim_create_buf(true, false)
+ unlisted_buf_float = api.nvim_open_win(unlisted_buf, true, float_opts)
insert('unlisted')
command('set nobuflisted')
- meths.set_current_win(old_win)
+ api.nvim_set_current_win(old_win)
end)
after_each(function()
expect('')
- eq(2, #meths.list_wins())
+ eq(2, #api.nvim_list_wins())
end)
it('if called from non-floating window', function()
- meths.buf_delete(old_buf, {force = true})
- eq(old_win, curwin().id)
+ api.nvim_buf_delete(old_buf, {force = true})
+ eq(old_win, curwin())
end)
it('if called from floating window with the same buffer', function()
- meths.set_current_win(same_buf_float)
+ api.nvim_set_current_win(same_buf_float)
command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')
command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')
- meths.buf_delete(old_buf, {force = true})
+ api.nvim_buf_delete(old_buf, {force = true})
eq(same_buf_float, eval('g:win_leave'))
eq(old_win, eval('g:win_enter'))
- eq(old_win, curwin().id)
+ eq(old_win, curwin())
end)
-- TODO: this case is too hard to deal with
pending('if called from floating window with an unlisted buffer', function()
- meths.set_current_win(unlisted_buf_float)
- meths.buf_delete(old_buf, {force = true})
+ api.nvim_set_current_win(unlisted_buf_float)
+ api.nvim_buf_delete(old_buf, {force = true})
end)
end)
end)
@@ -662,21 +669,21 @@ describe('float window', function()
command('botright vnew')
insert('unlisted')
command('set nobuflisted')
- meths.set_current_win(old_win)
- same_buf_float = meths.open_win(old_buf, false, float_opts).id
+ api.nvim_set_current_win(old_win)
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts)
end)
after_each(function()
expect('')
- eq(2, #meths.list_wins())
+ eq(2, #api.nvim_list_wins())
end)
it('if called from non-floating window with the deleted buffer', function()
- meths.buf_delete(old_buf, {force = true})
- eq(old_win, curwin().id)
+ api.nvim_buf_delete(old_buf, {force = true})
+ eq(old_win, curwin())
end)
it('if called from floating window with the deleted buffer', function()
- meths.set_current_win(same_buf_float)
- meths.buf_delete(old_buf, {force = true})
- eq(same_buf_float, curwin().id)
+ api.nvim_set_current_win(same_buf_float)
+ api.nvim_buf_delete(old_buf, {force = true})
+ eq(same_buf_float, curwin())
end)
end)
end)
@@ -688,63 +695,63 @@ describe('float window', function()
before_each(function()
insert('unlisted')
command('set nobuflisted')
- unlisted_buf = curbuf().id
+ unlisted_buf = curbuf()
command('tabnew')
insert('foo')
- old_buf = curbuf().id
- old_win = curwin().id
+ old_buf = curbuf()
+ old_win = curwin()
end)
describe('without splits, deleting the last listed buffer creates an empty buffer', function()
local same_buf_float
before_each(function()
- meths.set_current_win(old_win)
- same_buf_float = meths.open_win(old_buf, false, float_opts).id
+ api.nvim_set_current_win(old_win)
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts)
end)
after_each(function()
expect('')
- eq(2, #meths.list_wins())
- eq(2, #meths.list_tabpages())
+ eq(2, #api.nvim_list_wins())
+ eq(2, #api.nvim_list_tabpages())
end)
it('if called from non-floating window', function()
- meths.buf_delete(old_buf, {force = true})
- eq(old_win, curwin().id)
+ api.nvim_buf_delete(old_buf, {force = true})
+ eq(old_win, curwin())
end)
it('if called from non-floating window in another tabpage', function()
command('tab split')
- eq(3, #meths.list_tabpages())
- meths.buf_delete(old_buf, {force = true})
+ eq(3, #api.nvim_list_tabpages())
+ api.nvim_buf_delete(old_buf, {force = true})
end)
it('if called from floating window with the same buffer', function()
- meths.set_current_win(same_buf_float)
+ api.nvim_set_current_win(same_buf_float)
command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')
command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')
- meths.buf_delete(old_buf, {force = true})
+ api.nvim_buf_delete(old_buf, {force = true})
eq(same_buf_float, eval('g:win_leave'))
eq(old_win, eval('g:win_enter'))
- eq(old_win, curwin().id)
+ eq(old_win, curwin())
end)
end)
describe('with splits, deleting the last listed buffer creates an empty buffer', function()
local same_buf_float
before_each(function()
command('botright vsplit')
- meths.set_current_buf(unlisted_buf)
- meths.set_current_win(old_win)
- same_buf_float = meths.open_win(old_buf, false, float_opts).id
+ api.nvim_set_current_buf(unlisted_buf)
+ api.nvim_set_current_win(old_win)
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts)
end)
after_each(function()
expect('')
- eq(3, #meths.list_wins())
- eq(2, #meths.list_tabpages())
+ eq(3, #api.nvim_list_wins())
+ eq(2, #api.nvim_list_tabpages())
end)
it('if called from non-floating window with the deleted buffer', function()
- meths.buf_delete(old_buf, {force = true})
- eq(old_win, curwin().id)
+ api.nvim_buf_delete(old_buf, {force = true})
+ eq(old_win, curwin())
end)
it('if called from floating window with the deleted buffer', function()
- meths.set_current_win(same_buf_float)
- meths.buf_delete(old_buf, {force = true})
- eq(same_buf_float, curwin().id)
+ api.nvim_set_current_win(same_buf_float)
+ api.nvim_buf_delete(old_buf, {force = true})
+ eq(same_buf_float, curwin())
end)
end)
end)
@@ -753,48 +760,48 @@ describe('float window', function()
local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
local old_tabpage, old_buf, old_win
before_each(function()
- old_tabpage = curtab().id
+ old_tabpage = curtab()
insert('oldtab')
command('tabnew')
- old_buf = curbuf().id
- old_win = curwin().id
+ old_buf = curbuf()
+ old_win = curwin()
end)
describe('closing the last non-floating window', function()
describe('closes the tabpage when all floating windows are closeable', function()
local same_buf_float
before_each(function()
- same_buf_float = meths.open_win(old_buf, false, float_opts).id
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts)
end)
after_each(function()
- eq(old_tabpage, curtab().id)
+ eq(old_tabpage, curtab())
expect('oldtab')
- eq(1, #meths.list_tabpages())
+ eq(1, #api.nvim_list_tabpages())
end)
it('if called from non-floating window', function()
- meths.win_close(old_win, false)
+ api.nvim_win_close(old_win, false)
end)
it('if called from floating window', function()
- meths.set_current_win(same_buf_float)
- meths.win_close(old_win, false)
+ api.nvim_set_current_win(same_buf_float)
+ api.nvim_win_close(old_win, false)
end)
end)
describe('gives E5601 when there are non-closeable floating windows', function()
local other_buf_float
before_each(function()
command('set nohidden')
- local other_buf = meths.create_buf(true, false).id
- other_buf_float = meths.open_win(other_buf, true, float_opts).id
+ local other_buf = api.nvim_create_buf(true, false)
+ other_buf_float = api.nvim_open_win(other_buf, true, float_opts)
insert('foo')
- meths.set_current_win(old_win)
+ api.nvim_set_current_win(old_win)
end)
it('if called from non-floating window', function()
eq('Vim:E5601: Cannot close window, only floating window would remain',
- pcall_err(meths.win_close, old_win, false))
+ pcall_err(api.nvim_win_close, old_win, false))
end)
it('if called from floating window', function()
- meths.set_current_win(other_buf_float)
+ api.nvim_set_current_win(other_buf_float)
eq('Vim:E5601: Cannot close window, only floating window would remain',
- pcall_err(meths.win_close, old_win, false))
+ pcall_err(api.nvim_win_close, old_win, false))
end)
end)
end)
@@ -802,27 +809,27 @@ describe('float window', function()
describe('closes the tabpage when all floating windows are closeable', function()
local same_buf_float, other_buf, other_buf_float
before_each(function()
- same_buf_float = meths.open_win(old_buf, false, float_opts).id
- other_buf = meths.create_buf(true, false).id
- other_buf_float = meths.open_win(other_buf, true, float_opts).id
- meths.set_current_win(old_win)
+ same_buf_float = api.nvim_open_win(old_buf, false, float_opts)
+ other_buf = api.nvim_create_buf(true, false)
+ other_buf_float = api.nvim_open_win(other_buf, true, float_opts)
+ api.nvim_set_current_win(old_win)
end)
after_each(function()
- eq(old_tabpage, curtab().id)
+ eq(old_tabpage, curtab())
expect('oldtab')
- eq(1, #meths.list_tabpages())
+ eq(1, #api.nvim_list_tabpages())
end)
it('if called from non-floating window', function()
- meths.buf_delete(old_buf, {force = false})
+ api.nvim_buf_delete(old_buf, {force = false})
end)
it('if called from floating window with the same buffer', function()
- meths.set_current_win(same_buf_float)
- meths.buf_delete(old_buf, {force = false})
+ api.nvim_set_current_win(same_buf_float)
+ api.nvim_buf_delete(old_buf, {force = false})
end)
-- TODO: this case is too hard to deal with
pending('if called from floating window with another buffer', function()
- meths.set_current_win(other_buf_float)
- meths.buf_delete(old_buf, {force = false})
+ api.nvim_set_current_win(other_buf_float)
+ api.nvim_buf_delete(old_buf, {force = false})
end)
end)
-- TODO: what to do when there are non-closeable floating windows?
@@ -862,36 +869,27 @@ describe('float window', function()
[24] = {foreground = Screen.colors.Black, background = Screen.colors.Grey80};
[25] = {blend = 100, background = Screen.colors.Gray0};
[26] = {blend = 80, background = Screen.colors.Gray0};
- [27] = {background = Screen.colors.LightGray};
- [28] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray};
+ [27] = {foreground = Screen.colors.Black, background = Screen.colors.LightGrey};
+ [28] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey};
}
screen:set_default_attr_ids(attrs)
end)
it('can be created and reconfigured', function()
- local buf = meths.create_buf(false,false)
- local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
+ local buf = api.nvim_create_buf(false,false)
+ local win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
local expected_pos = {
- [4]={{id=1001}, 'NW', 1, 2, 5, true},
+ [4]={1001, 'NW', 1, 2, 5, true},
}
if multigrid then
screen:expect{grid=[[
## grid 1
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
+ [2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*5
## grid 3
|
## grid 4
@@ -904,33 +902,23 @@ describe('float window', function()
{0:~ }|
{0:~ }{1: }{0: }|
{0:~ }{2:~ }{0: }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
|
]])
end
- meths.win_set_config(win, {relative='editor', row=0, col=10})
+ api.nvim_win_set_config(win, {relative='editor', row=0, col=10})
expected_pos[4][4] = 0
expected_pos[4][5] = 10
if multigrid then
screen:expect{grid=[[
## grid 1
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
+ [2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*5
## grid 3
|
## grid 4
@@ -941,43 +929,27 @@ describe('float window', function()
screen:expect([[
^ {1: } |
{0:~ }{2:~ }{0: }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*4
|
]])
end
- meths.win_close(win, false)
+ api.nvim_win_close(win, false)
if multigrid then
screen:expect([[
## grid 1
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
+ [2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*5
## grid 3
|
]])
else
screen:expect([[
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*5
|
]])
end
@@ -985,39 +957,29 @@ describe('float window', function()
it('window position fixed', function()
command('rightbelow 20vsplit')
- local buf = meths.create_buf(false,false)
- local win = meths.open_win(buf, false, {
+ local buf = api.nvim_create_buf(false,false)
+ local win = api.nvim_open_win(buf, false, {
relative='win', width=15, height=2, row=2, col=10, anchor='NW', fixed=true})
if multigrid then
screen:expect{grid=[[
## grid 1
- [2:-------------------]{5:│}[4:--------------------]|
- [2:-------------------]{5:│}[4:--------------------]|
- [2:-------------------]{5:│}[4:--------------------]|
- [2:-------------------]{5:│}[4:--------------------]|
- [2:-------------------]{5:│}[4:--------------------]|
+ [2:-------------------]{5:│}[4:--------------------]|*5
{5:[No Name] }{4:[No Name] }|
[3:----------------------------------------]|
## grid 2
|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*4
## grid 3
|
## grid 4
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*4
## grid 5
{1: }|
{2:~ }|
]], float_pos={
- [5] = {{id = 1002}, "NW", 4, 2, 10, true};
+ [5] = {1002, "NW", 4, 2, 10, true};
}}
else
screen:expect([[
@@ -1031,7 +993,7 @@ describe('float window', function()
]])
end
- meths.win_set_config(win, {fixed=false})
+ api.nvim_win_set_config(win, {fixed=false})
if multigrid then
screen:expect_unchanged()
@@ -1055,29 +1017,20 @@ describe('float window', function()
-- or something.
command("set redrawdebug=compositor")
command("set wd=1")
- local buf = meths.create_buf(false,false)
- local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
+ local buf = api.nvim_create_buf(false,false)
+ local win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
local expected_pos = {
- [4]={{id=1001}, 'NW', 1, 2, 5, true},
+ [4]={1001, 'NW', 1, 2, 5, true},
}
if multigrid then
screen:expect{grid=[[
## grid 1
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
+ [2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*5
## grid 3
|
## grid 4
@@ -1090,33 +1043,23 @@ describe('float window', function()
{0:~ }|
{0:~ }{1: }{0: }|
{0:~ }{2:~ }{0: }|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
|
]])
end
- meths.win_set_config(win, {relative='editor', row=0, col=10})
+ api.nvim_win_set_config(win, {relative='editor', row=0, col=10})
expected_pos[4][4] = 0
expected_pos[4][5] = 10
if multigrid then
screen:expect{grid=[[
## grid 1
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
- [2:----------------------------------------]|
+ [2:----------------------------------------]|*6
[3:----------------------------------------]|
## grid 2
^ |
- {0:~ }|
- {0:~ }|
-