2024-04-20 08:44:13 -07:00
|
|
|
local n = require('test.functional.testnvim')()
|
2016-07-01 03:26:20 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2024-04-20 08:44:13 -07:00
|
|
|
|
|
|
|
local command = n.command
|
|
|
|
local clear, feed, feed_command = n.clear, n.feed, n.feed_command
|
|
|
|
local exec = n.exec
|
2016-07-01 03:26:20 -07:00
|
|
|
|
|
|
|
describe(':drop', function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
screen = Screen.new(35, 10)
|
|
|
|
screen:set_default_attr_ids({
|
2016-08-09 06:11:04 -07:00
|
|
|
[0] = { bold = true, foreground = Screen.colors.Blue },
|
2016-07-01 03:26:20 -07:00
|
|
|
[1] = { bold = true, reverse = true },
|
|
|
|
[2] = { reverse = true },
|
|
|
|
[3] = { bold = true },
|
|
|
|
})
|
2024-03-20 16:34:43 -07:00
|
|
|
command('set nohidden laststatus=2 shortmess-=F')
|
2016-07-01 03:26:20 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('works like :e when called with only one window open', function()
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('drop tmp1.vim')
|
2016-07-01 03:26:20 -07:00
|
|
|
screen:expect([[
|
|
|
|
^ |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }|*7
|
2016-07-01 03:26:20 -07:00
|
|
|
{1:tmp1.vim }|
|
2020-06-12 17:26:04 -07:00
|
|
|
"tmp1.vim" [New] |
|
2016-07-01 03:26:20 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('switches to an open window showing the buffer', function()
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('edit tmp1')
|
|
|
|
feed_command('vsplit')
|
|
|
|
feed_command('edit tmp2')
|
|
|
|
feed_command('drop tmp1')
|
2016-07-01 03:26:20 -07:00
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
│^ |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }│{0:~ }|*7
|
2016-07-01 03:26:20 -07:00
|
|
|
{2:tmp2 }{1:tmp1 }|
|
2024-01-23 16:29:33 -07:00
|
|
|
"tmp1" [New] |
|
2016-07-01 03:26:20 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("splits off a new window when a buffer can't be abandoned", function()
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('edit tmp1')
|
|
|
|
feed_command('vsplit')
|
|
|
|
feed_command('edit tmp2')
|
2016-07-01 03:26:20 -07:00
|
|
|
feed('iABC<esc>')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('drop tmp3')
|
2016-07-01 03:26:20 -07:00
|
|
|
screen:expect([[
|
2022-05-15 09:34:44 -07:00
|
|
|
^ │ |
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }│{0:~ }|*3
|
2022-05-15 09:34:44 -07:00
|
|
|
{1:tmp3 }│{0:~ }|
|
|
|
|
ABC │{0:~ }|
|
2023-12-09 05:42:00 -07:00
|
|
|
{0:~ }│{0:~ }|*2
|
2016-07-01 03:26:20 -07:00
|
|
|
{2:tmp2 [+] tmp1 }|
|
2020-06-12 17:26:04 -07:00
|
|
|
"tmp3" [New] |
|
2016-07-01 03:26:20 -07:00
|
|
|
]])
|
|
|
|
end)
|
2024-03-20 16:34:43 -07:00
|
|
|
|
|
|
|
-- oldtest: Test_drop_modified_file()
|
|
|
|
it('does not cause E37 with modified same file', function()
|
|
|
|
exec([[
|
|
|
|
edit Xdrop_modified.txt
|
|
|
|
call setline(1, 'The quick brown fox jumped over the lazy dogs')
|
|
|
|
]])
|
|
|
|
feed_command('drop Xdrop_modified.txt')
|
|
|
|
screen:expect([[
|
|
|
|
^The quick brown fox jumped over the|
|
|
|
|
lazy dogs |
|
|
|
|
{0:~ }|*6
|
|
|
|
{1:Xdrop_modified.txt [+] }|
|
2024-03-21 14:54:12 -07:00
|
|
|
:drop Xdrop_modified.txt |
|
2024-03-20 16:34:43 -07:00
|
|
|
]])
|
|
|
|
end)
|
2016-07-01 03:26:20 -07:00
|
|
|
end)
|