diff options
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r-- | test/functional/ui/float_spec.lua | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 6759510ad1..60952543e7 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -462,6 +462,9 @@ describe('float window', function() end) end) describe("deleting the last non-floating window's buffer", function() + after_each(function() + eq(false, meths.buf_is_valid(old_buf)) + end) describe('leaves one window with an empty buffer when there is only one buffer', function() local same_buf_float before_each(function() @@ -552,6 +555,9 @@ describe('float window', function() end) end) describe('with splits, deleting the last listed buffer creates an empty buffer', function() + after_each(function() + eq(false, meths.buf_is_valid(old_buf)) + end) describe('when a non-floating window has an unlisted buffer', function() local same_buf_float before_each(function() @@ -597,6 +603,7 @@ describe('float window', function() same_buf_float = meths.open_win(old_buf, false, float_opts).id end) after_each(function() + eq(false, meths.buf_is_valid(old_buf)) expect('') eq(2, #meths.list_wins()) eq(2, #meths.list_tabpages()) @@ -629,6 +636,7 @@ describe('float window', function() same_buf_float = meths.open_win(old_buf, false, float_opts).id end) after_each(function() + eq(false, meths.buf_is_valid(old_buf)) expect('') eq(3, #meths.list_wins()) eq(2, #meths.list_tabpages()) @@ -656,12 +664,18 @@ describe('float window', function() old_win = curwin().id end) describe('closing the last non-floating window', function() - describe('closes the tabpage when all floating windows are closeable', function() - local same_buf_float + describe('closes the tabpage force-closing floating windows', function() + local same_buf_float, other_buf, other_buf_float before_each(function() + command('set nohidden') 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 + insert('foo') + meths.set_current_win(old_win) end) after_each(function() + eq(true, meths.buf_is_valid(other_buf)) eq(old_tabpage, curtab().id) expect('oldtab') eq(1, #meths.list_tabpages()) @@ -669,41 +683,30 @@ describe('float window', function() it('if called from non-floating window', function() meths.win_close(old_win, false) end) - it('if called from floating window', function() + it('if called from floating window with the same buffer', function() meths.set_current_win(same_buf_float) meths.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 - insert('foo') - meths.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)) - end) - it('if called from floating window', function() + it('if called from floating window with another buffer', function() meths.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)) + meths.win_close(old_win, false) end) end) end) describe("deleting the last non-floating window's buffer", function() - describe('closes the tabpage when all floating windows are closeable', function() + describe('closes the tabpage force-closing floating windows', function() local same_buf_float, other_buf, other_buf_float before_each(function() + command('set nohidden') 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 + insert('foo') meths.set_current_win(old_win) end) after_each(function() + eq(false, meths.buf_is_valid(old_buf)) + eq(true, meths.buf_is_valid(other_buf)) eq(old_tabpage, curtab().id) expect('oldtab') eq(1, #meths.list_tabpages()) @@ -721,7 +724,6 @@ 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) |