2016-07-01 03:26:20 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2018-06-21 23:18:02 -07:00
|
|
|
local command = helpers.command
|
2016-07-01 03:26:20 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2017-04-08 14:12:26 -07:00
|
|
|
local clear, feed, feed_command = helpers.clear, helpers.feed, helpers.feed_command
|
2024-03-20 16:34:43 -07:00
|
|
|
local exec = helpers.exec
|
2016-07-01 03:26:20 -07:00
|
|
|
|
|
|
|
describe(':drop', function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
screen = Screen.new(35, 10)
|
|
|
|
screen:attach()
|
|
|
|
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 [+] }|
|
|
|
|
"Xdrop_modified.txt" [New] |
|
|
|
|
]])
|
|
|
|
end)
|
2016-07-01 03:26:20 -07:00
|
|
|
end)
|