aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/float_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-03-24 09:28:23 +0800
committerGitHub <noreply@github.com>2022-03-24 09:28:23 +0800
commit2e3611784011a82be239341c00d435cb7cf7b711 (patch)
treee2cba97c1fe9ddc9b40da28cf14d9cb2b4c84a84 /test/functional/ui/float_spec.lua
parentd3af109d10b2adab23ce2e95d99f0ffb642c7c42 (diff)
downloadrneovim-2e3611784011a82be239341c00d435cb7cf7b711.tar.gz
rneovim-2e3611784011a82be239341c00d435cb7cf7b711.tar.bz2
rneovim-2e3611784011a82be239341c00d435cb7cf7b711.zip
test: add test for deleting last listed buffer when there are floats (#17833)
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r--test/functional/ui/float_spec.lua44
1 files changed, 37 insertions, 7 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 7192b95e45..87aa6ffcbe 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -443,7 +443,7 @@ describe('float window', function()
before_each(function()
insert('foo')
end)
- describe('when there is only one buffer leaves that window with an empty buffer', function()
+ describe('leaves one window with an empty buffer when there is only one buffer', function()
before_each(function()
meths.open_win(old_buf, true, float_opts)
end)
@@ -461,8 +461,8 @@ describe('float window', function()
eq(1, #meths.list_wins())
end)
end)
- describe('when there are other buffers closes other windows with that buffer', function()
- local other_buf, same_buf_win, other_buf_win
+ describe('closes other windows with that buffer when there are other buffers', function()
+ local same_buf_win, other_buf, other_buf_win
before_each(function()
same_buf_win = meths.open_win(old_buf, false, float_opts)
other_buf = meths.create_buf(true, false)
@@ -491,6 +491,35 @@ describe('float window', function()
meths.buf_delete(old_buf, {force = true})
end)
end)
+ describe('creates a new buffer when there is only one listed buffer', function()
+ local same_buf_win, unlisted_buf, unlisted_buf_win
+ before_each(function()
+ same_buf_win = meths.open_win(old_buf, false, float_opts)
+ unlisted_buf = meths.create_buf(true, false)
+ unlisted_buf_win = meths.open_win(unlisted_buf, true, float_opts)
+ insert('bar')
+ command('set nobuflisted')
+ meths.set_current_win(old_win)
+ end)
+ it('if called from non-floating window', function()
+ meths.buf_delete(old_buf, {force = true})
+ eq(old_win, meths.get_current_win())
+ expect('')
+ eq(2, #meths.list_wins())
+ end)
+ it('if called from floating window with the same buffer', function()
+ meths.set_current_win(same_buf_win)
+ meths.buf_delete(old_buf, {force = true})
+ eq(old_win, meths.get_current_win())
+ expect('')
+ eq(2, #meths.list_wins())
+ 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_win)
+ meths.buf_delete(old_buf, {force = true})
+ end)
+ end)
end)
end)
@@ -505,7 +534,7 @@ describe('float window', function()
old_win = meths.get_current_win()
end)
describe('closing the last non-floating window', function()
- describe('when all floating windows are closeable closes the tabpage', function()
+ describe('closes the tabpage when all floating windows are closeable', function()
before_each(function()
meths.open_win(old_buf, true, float_opts)
end)
@@ -523,7 +552,7 @@ describe('float window', function()
eq(1, #meths.list_tabpages())
end)
end)
- describe('when there are non-closeable floating windows gives E5601', function()
+ describe('gives E5601 when there are non-closeable floating windows', function()
before_each(function()
command('set nohidden')
local other_buf = meths.create_buf(true, false)
@@ -542,8 +571,8 @@ describe('float window', function()
end)
end)
describe("deleting the last non-floating window's buffer", function()
- describe('when all floating windows are closeable closes the tabpage', function()
- local other_buf, same_buf_win, other_buf_win
+ describe('closes the tabpage when all floating windows are closeable', function()
+ local same_buf_win, other_buf, other_buf_win
before_each(function()
same_buf_win = meths.open_win(old_buf, false, float_opts)
other_buf = meths.create_buf(true, false)
@@ -569,6 +598,7 @@ describe('float window', function()
meths.buf_delete(old_buf, {force = false})
end)
end)
+ -- TODO: what to do when there are non-closeable floating windows?
end)
end)