Skip to content

Commit 3725343

Browse files
committed
fix: broken features
1 parent 932ea86 commit 3725343

2 files changed

Lines changed: 281 additions & 2 deletions

File tree

‎tests/test_integrations.lua‎

Lines changed: 170 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,44 @@ T["left integration"]["opening closes zen side buffer, closing reopens it"] = fu
3636
})
3737
end
3838

39+
T["left integration"]["opening a left integration preserves an existing top integration"] = function()
40+
child.cmd("Git")
41+
child.lua("vim.cmd('Fyler kind=split_left_most')")
42+
43+
Helpers.expect.layout(child, {
44+
type = "col",
45+
children = {
46+
{ type = "leaf", filetype = "fugitive", buftype = "nowrite", width = 240, height = 25 },
47+
{
48+
type = "row",
49+
children = {
50+
{ type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 46, height = 24 },
51+
{ type = "leaf", filetype = "", buftype = "", width = 146, height = 24 },
52+
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 24 },
53+
},
54+
},
55+
},
56+
})
57+
58+
child.cmd("close")
59+
child.lua("vim.cmd('Fyler kind=split_left_most')")
60+
child.cmd("close")
61+
62+
Helpers.expect.layout(child, {
63+
type = "col",
64+
children = {
65+
{ type = "leaf", filetype = "fugitive", buftype = "nowrite", width = 240, height = 25 },
66+
{
67+
type = "row",
68+
children = {
69+
{ type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 24 },
70+
{ type = "leaf", filetype = "", buftype = "", width = 146, height = 24 },
71+
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 24 },
72+
},
73+
},
74+
},
75+
})
76+
end
3977

4078
T["left integration"]["opening an integration should close the existing integration on the same side"] = function()
4179
child.cmd("Fyler kind=split_left_most")
@@ -61,6 +99,45 @@ T["left integration"]["opening an integration should close the existing integrat
6199
})
62100
end
63101

102+
T["left integration"]["opening a left integration preserves an existing bottom integration"] = function()
103+
child.cmd("Trouble diagnostics")
104+
child.cmd("Fyler kind=split_left_most")
105+
106+
Helpers.expect.layout(child, {
107+
type = "col",
108+
children = {
109+
{
110+
type = "row",
111+
children = {
112+
{ type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 46, height = 39 },
113+
{ type = "leaf", filetype = "", buftype = "", width = 146, height = 39 },
114+
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 39 },
115+
},
116+
},
117+
{ type = "leaf", filetype = "trouble", buftype = "nofile", width = 240, height = 10 },
118+
},
119+
})
120+
121+
child.cmd("close")
122+
child.cmd("Fyler kind=split_left_most")
123+
child.cmd("close")
124+
125+
Helpers.expect.layout(child, {
126+
type = "col",
127+
children = {
128+
{
129+
type = "row",
130+
children = {
131+
{ type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 39 },
132+
{ type = "leaf", filetype = "", buftype = "", width = 146, height = 39 },
133+
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 39 },
134+
},
135+
},
136+
{ type = "leaf", filetype = "trouble", buftype = "nofile", width = 240, height = 10 },
137+
},
138+
})
139+
end
140+
64141
T["top integration"] = MiniTest.new_set({})
65142

66143
T["top integration"]["opening"] = function()
@@ -257,9 +334,70 @@ T["right integration"]["opening an integration with table filetype"] = function(
257334
})
258335
end
259336

337+
T["combined"] = MiniTest.new_set({})
338+
339+
T["combined"]["opening a side integration preserves existing top and bottom integrations"] = function()
340+
child.cmd("Git")
341+
child.cmd("Trouble diagnostics")
342+
child.cmd("Fyler kind=split_left_most")
343+
344+
Helpers.expect.layout(child, {
345+
type = "col",
346+
children = {
347+
{ type = "leaf", filetype = "fugitive", buftype = "nowrite", width = 240, height = 25 },
348+
{
349+
type = "row",
350+
children = {
351+
{ type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 46, height = 13 },
352+
{ type = "leaf", filetype = "", buftype = "", width = 146, height = 13 },
353+
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 13 },
354+
},
355+
},
356+
{ type = "leaf", filetype = "trouble", buftype = "nofile", width = 240, height = 10 },
357+
},
358+
})
359+
360+
child.cmd("close")
361+
child.cmd("Fyler kind=split_left_most")
362+
child.cmd("close")
363+
364+
Helpers.expect.layout(child, {
365+
type = "col",
366+
children = {
367+
{ type = "leaf", filetype = "fugitive", buftype = "nowrite", width = 240, height = 25 },
368+
{
369+
type = "row",
370+
children = {
371+
{ type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 13 },
372+
{ type = "leaf", filetype = "", buftype = "", width = 146, height = 13 },
373+
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 13 },
374+
},
375+
},
376+
{ type = "leaf", filetype = "trouble", buftype = "nofile", width = 240, height = 10 },
377+
},
378+
})
379+
380+
child.cmd("Trouble close")
381+
382+
Helpers.expect.layout(child, {
383+
type = "col",
384+
children = {
385+
{ type = "leaf", filetype = "fugitive", buftype = "nowrite", width = 240, height = 25 },
386+
{
387+
type = "row",
388+
children = {
389+
{ type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 24 },
390+
{ type = "leaf", filetype = "", buftype = "", width = 146, height = 24 },
391+
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 24 },
392+
},
393+
},
394+
},
395+
})
396+
end
397+
260398
local min_width_child = MiniTest.new_child_neovim()
261399

262-
T["min_width"] = MiniTest.new_set({
400+
T["min width"] = MiniTest.new_set({
263401
hooks = {
264402
pre_case = function()
265403
min_width_child.restart({ "-u", "tests/scripts/init_with_zen_min_width.lua" })
@@ -268,7 +406,7 @@ T["min_width"] = MiniTest.new_set({
268406
},
269407
})
270408

271-
T["min_width"]["integration with a larger min_width should override the wildcard default"] = function()
409+
T["min width"]["integration with a larger min_width should override the wildcard default"] = function()
272410
min_width_child.lua([[vim.o.splitright = true; require("CopilotChat").open()]])
273411

274412
Helpers.expect.layout(min_width_child, {
@@ -281,4 +419,34 @@ T["min_width"]["integration with a larger min_width should override the wildcard
281419
})
282420
end
283421

422+
T["small window integration"] = MiniTest.new_set()
423+
424+
T["small window integration"]["left integration should keep its natural width"] = function()
425+
child.restart({ "-u", "tests/scripts/init_with_zen_small.lua" })
426+
child.cmd("Fyler kind=split_left_most")
427+
428+
-- Fyler opens at 30% of 140 = 42 cols. Zen must not force it to 0.
429+
Helpers.expect.layout(child, {
430+
type = "row",
431+
children = {
432+
{ type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 42, height = 50 },
433+
{ type = "leaf", filetype = "", buftype = "", width = 97, height = 50 },
434+
},
435+
})
436+
end
437+
438+
T["small window integration"]["right integration should keep its natural width"] = function()
439+
child.restart({ "-u", "tests/scripts/init_with_zen_small.lua" })
440+
child.cmd("Neotest summary open")
441+
442+
-- Neotest opens at vertical resize 50. Zen must not force it to 0.
443+
Helpers.expect.layout(child, {
444+
type = "row",
445+
children = {
446+
{ type = "leaf", filetype = "", buftype = "", width = 89, height = 50 },
447+
{ type = "leaf", filetype = "neotest-summary", buftype = "nofile", width = 50, height = 50 },
448+
},
449+
})
450+
end
451+
284452
return T

‎tests/test_wincmd.lua‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
local Helpers = dofile("tests/scripts/helpers.lua")
2+
local child = MiniTest.new_child_neovim()
3+
4+
local T = MiniTest.new_set({
5+
hooks = {
6+
pre_case = function()
7+
child.restart({ "-u", "tests/scripts/init_with_zen.lua" })
8+
end,
9+
post_once = child.stop,
10+
},
11+
})
12+
13+
T["moving a window to the side does not go past zen buffers"] = function()
14+
child.cmd("wincmd H")
15+
16+
Helpers.expect.layout(child, {
17+
type = "row",
18+
children = {
19+
{ type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 50 },
20+
{ type = "leaf", filetype = "", buftype = "", width = 146, height = 50 },
21+
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 50 },
22+
},
23+
})
24+
25+
child.cmd("wincmd L")
26+
27+
Helpers.expect.layout(child, {
28+
type = "row",
29+
children = {
30+
{ type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 50 },
31+
{ type = "leaf", filetype = "", buftype = "", width = 146, height = 50 },
32+
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 50 },
33+
},
34+
})
35+
end
36+
37+
T["moving a window to the side does not go past integrations"] = function()
38+
child.cmd("Fyler kind=split_left_most")
39+
child.cmd("Neotest summary open")
40+
41+
child.cmd("wincmd H")
42+
43+
Helpers.expect.layout(child, {
44+
type = "row",
45+
children = {
46+
{ type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 46, height = 50 },
47+
{ type = "leaf", filetype = "", buftype = "", width = 146, height = 50 },
48+
{ type = "leaf", filetype = "neotest-summary", buftype = "nofile", width = 46, height = 50 },
49+
},
50+
})
51+
52+
child.cmd("wincmd L")
53+
54+
Helpers.expect.layout(child, {
55+
type = "row",
56+
children = {
57+
{ type = "leaf", filetype = "fyler_finder", buftype = "acwrite", width = 46, height = 50 },
58+
{ type = "leaf", filetype = "", buftype = "", width = 146, height = 50 },
59+
{ type = "leaf", filetype = "neotest-summary", buftype = "nofile", width = 46, height = 50 },
60+
},
61+
})
62+
end
63+
64+
T["hsplit"] = MiniTest.new_set({})
65+
66+
T["hsplit"]["moving a window below keeps it between zen buffers"] = function()
67+
child.cmd("edit test.lua")
68+
child.cmd("split test.rs")
69+
70+
child.cmd("wincmd J")
71+
72+
Helpers.expect.layout(child, {
73+
type = "row",
74+
children = {
75+
{ type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 50 },
76+
{
77+
type = "col",
78+
children = {
79+
{ type = "leaf", filetype = "lua", buftype = "", width = 146, height = 24 },
80+
{ type = "leaf", filetype = "rust", buftype = "", width = 146, height = 25 },
81+
},
82+
},
83+
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 50 },
84+
},
85+
})
86+
end
87+
88+
T["hsplit"]["moving a window above keeps it between zen buffers"] = function()
89+
child.cmd("edit test.lua")
90+
child.cmd("split test.rs")
91+
92+
child.cmd("wincmd j")
93+
child.cmd("wincmd K")
94+
95+
Helpers.expect.layout(child, {
96+
type = "row",
97+
children = {
98+
{ type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 50 },
99+
{
100+
type = "col",
101+
children = {
102+
{ type = "leaf", filetype = "rust", buftype = "", width = 146, height = 24 },
103+
{ type = "leaf", filetype = "lua", buftype = "", width = 146, height = 25 },
104+
},
105+
},
106+
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 50 },
107+
},
108+
})
109+
end
110+
111+
return T

0 commit comments

Comments
 (0)