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
|
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},
|
|
|
|
})
|
2018-06-21 23:18:02 -07:00
|
|
|
command("set 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([[
|
|
|
|
^ |
|
2016-08-09 06:11:04 -07:00
|
|
|
{0:~ }|
|
|
|
|
{0:~ }|
|
|
|
|
{0:~ }|
|
|
|
|
{0:~ }|
|
|
|
|
{0:~ }|
|
|
|
|
{0:~ }|
|
|
|
|
{0:~ }|
|
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([[
|
2018-02-08 16:44:24 -07:00
|
|
|
{2:│}^ |
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
2016-07-01 03:26:20 -07:00
|
|
|
{2:tmp2 }{1:tmp1 }|
|
|
|
|
:drop tmp1 |
|
|
|
|
]])
|
|
|
|
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([[
|
2018-02-08 16:44:24 -07:00
|
|
|
^ {2:│} |
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
|
|
|
{1:tmp3 }{2:│}{0:~ }|
|
|
|
|
ABC {2:│}{0:~ }|
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
|
|
|
{0:~ }{2:│}{0:~ }|
|
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)
|
|
|
|
|
|
|
|
end)
|