mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: add test for deleting last listed buffer when there are floats (#17833)
This commit is contained in:
parent
d3af109d10
commit
2e36117840
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user