aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/float_spec.lua
diff options
context:
space:
mode:
authorSean Dewar <6256228+seandewar@users.noreply.github.com>2024-02-23 09:49:28 +0000
committerSean Dewar <6256228+seandewar@users.noreply.github.com>2024-03-08 23:24:04 +0000
commit66f331fef7ad3df480bd02f1705e176d1a07c785 (patch)
tree80761bdbc0464735e2d628e7624d28903d895f09 /test/functional/ui/float_spec.lua
parenta70eae57bd44208a77b5ac29839e8a39ab3c9cd8 (diff)
downloadrneovim-66f331fef7ad3df480bd02f1705e176d1a07c785.tar.gz
rneovim-66f331fef7ad3df480bd02f1705e176d1a07c785.tar.bz2
rneovim-66f331fef7ad3df480bd02f1705e176d1a07c785.zip
vim-patch:9.1.0116: win_split_ins may not check available room
Problem: win_split_ins has no check for E36 when moving an existing window Solution: check for room and fix the issues in f_win_splitmove() (Sean Dewar) https://github.com/vim/vim/commit/0fd44a5ad81ade342cb54d8984965bdedd2272c8 Omit WSP_FORCE_ROOM, as it's not needed for Nvim's autocmd window, which is floating. Shouldn't be difficult to port later if it's used for anything else. Make win_splitmove continue working for turning floating windows into splits. Move the logic for "unfloating" a float to win_split_ins; unlike splits, no changes to the window layout are needed before calling it, as floats take no room in the window layout and cannot affect the e_noroom check. Add missing tp_curwin-fixing logic for turning external windows into splits, and add a test. NOTE: there are other issues with the way "tabpage independence" is implemented for external windows; namely, some things assume that tp_curwin is indeed a window within that tabpage, and as such, functions like tabpage_winnr and nvim_tabpage_get_win currently don't always work for external windows (with the latter aborting!) Use last_status over frame_add_statusline, as Nvim's last_status already does this for all windows in the current tabpage. Adjust restore_full_snapshot_rec to handle this. This "restore everything" approach is changed in a future commit anyway, so only ensure it's robust enough to just pass tests. Keep check_split_disallowed's current doc comment, as it's actually a bit more accurate here. (I should probably PR Vim to use this one) Allow f_win_splitmove to move a floating "wp" into a split; Nvim supports this. Continue to disallow it from moving the autocommand window into a split (funnily enough, the check wasn't reachable before, as moving a float was disallowed), but now return -1 in that case (win_splitmove also returns FAIL for this, but handling it in f_win_splitmove avoids us needing to switch windows first). Cherry-pick Test_window_split_no_room fix from v9.1.0121. Update nvim_win_set_config to handle win_split_ins failure in later commits.
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r--test/functional/ui/float_spec.lua53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index cdb3b79963..e324d03b30 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -550,6 +550,43 @@ describe('float window', function()
eq({ w0 }, api.nvim_list_wins())
end)
+ it('win_splitmove() can move float into a split', function()
+ command('split')
+ eq({'col', {{'leaf', 1001}, {'leaf', 1000}}}, fn.winlayout())
+
+ local win1 = api.nvim_open_win(0, true, {relative = 'editor', row = 1, col = 1, width = 5, height = 5})
+ fn.win_splitmove(win1, 1001, {vertical = true})
+ eq({'col', {{'row', {{'leaf', win1}, {'leaf', 1001}}}, {'leaf', 1000}}}, fn.winlayout())
+ eq('', api.nvim_win_get_config(win1).relative)
+
+ -- Should be unable to create a split relative to a float, though.
+ local win2 = api.nvim_open_win(0, true, {relative = 'editor', row = 1, col = 1, width = 5, height = 5})
+ eq('Vim:E957: Invalid window number', pcall_err(fn.win_splitmove, win1, win2, {vertical = true}))
+ end)
+
+ it('tp_curwin updated if external window is moved into split', function()
+ local screen = Screen.new(20, 7)
+ screen:attach { ext_multigrid = true }
+
+ command('tabnew')
+ local external_win = api.nvim_open_win(0, true, {external = true, width = 5, height = 5})
+ eq(external_win, api.nvim_get_current_win())
+ eq(2, fn.tabpagenr())
+ command('tabfirst')
+ api.nvim_set_current_win(external_win)
+ eq(external_win, api.nvim_get_current_win())
+ eq(1, fn.tabpagenr())
+
+ command('wincmd J')
+ eq(external_win, api.nvim_get_current_win())
+ eq(false, api.nvim_win_get_config(external_win).external)
+ command('tabnext')
+ eq(2, fn.tabpagenr())
+ neq(external_win, api.nvim_get_current_win())
+
+ screen:detach()
+ end)
+
describe('with only one tabpage,', function()
local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
local old_buf, old_win
@@ -9101,6 +9138,22 @@ describe('float window', function()
]]}
end
end)
+
+ it('attempt to turn into split with no room', function()
+ eq('Vim(split):E36: Not enough room', pcall_err(command, 'execute "split |"->repeat(&lines)'))
+ command('vsplit | wincmd | | wincmd p')
+ api.nvim_open_win(0, true, {relative = "editor", row = 0, col = 0, width = 5, height = 5})
+ local config = api.nvim_win_get_config(0)
+ eq('editor', config.relative)
+
+ local layout = fn.winlayout()
+ local restcmd = fn.winrestcmd()
+ eq('Vim(wincmd):E36: Not enough room', pcall_err(command, 'wincmd K'))
+ eq('Vim(wincmd):E36: Not enough room', pcall_err(command, 'wincmd J'))
+ eq(layout, fn.winlayout())
+ eq(restcmd, fn.winrestcmd())
+ eq(config, api.nvim_win_get_config(0))
+ end)
end
describe('with ext_multigrid', function()