1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
local helpers = require('test.functional.helpers')(after_each)
local command = helpers.command
local Screen = require('test.functional.ui.screen')
local clear, feed, feed_command = helpers.clear, helpers.feed, helpers.feed_command
describe(":drop", function()
local screen
before_each(function()
clear()
screen = Screen.new(35, 10)
screen:attach()
screen:set_default_attr_ids({
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {bold = true, reverse = true},
[2] = {reverse = true},
[3] = {bold = true},
})
command("set laststatus=2 shortmess-=F")
end)
it("works like :e when called with only one window open", function()
feed_command("drop tmp1.vim")
screen:expect([[
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{1:tmp1.vim }|
"tmp1.vim" [New] |
]])
end)
it("switches to an open window showing the buffer", function()
feed_command("edit tmp1")
feed_command("vsplit")
feed_command("edit tmp2")
feed_command("drop tmp1")
screen:expect([[
│^ |
{0:~ }│{0:~ }|
{0:~ }│{0:~ }|
{0:~ }│{0:~ }|
{0:~ }│{0:~ }|
{0:~ }│{0:~ }|
{0:~ }│{0:~ }|
{0:~ }│{0:~ }|
{2:tmp2 }{1:tmp1 }|
:drop tmp1 |
]])
end)
it("splits off a new window when a buffer can't be abandoned", function()
command("set nohidden")
feed_command("edit tmp1")
feed_command("vsplit")
feed_command("edit tmp2")
feed("iABC<esc>")
feed_command("drop tmp3")
screen:expect([[
^ │ |
{0:~ }│{0:~ }|
{0:~ }│{0:~ }|
{0:~ }│{0:~ }|
{1:tmp3 }│{0:~ }|
ABC │{0:~ }|
{0:~ }│{0:~ }|
{0:~ }│{0:~ }|
{2:tmp2 [+] tmp1 }|
"tmp3" [New] |
]])
end)
end)
|