Skip to content

Commit c011788

Browse files
phanenibhagwan
authored andcommitted
test: toggle_behavior=extend|default
test: cannot shorten path by modifying table ref fix(win): don't enlarge size for fzf previewer test: filter args (`make test filter="^win.*toggle%s.*[!E]F"`)
1 parent 7e72585 commit c011788

69 files changed

Lines changed: 1391 additions & 36 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lua/fzf-lua/test/previewer.lua

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
local fzf = require("fzf-lua")
22
local builtin = require("fzf-lua.previewer.builtin")
3-
local M = builtin.base:extend()
3+
local M = {}
4+
M.builtin = builtin.base:extend()
5+
M.fzf = require("fzf-lua.previewer.fzf").base:extend()
46

5-
function M:new(o, opts, fzf_win)
6-
M.super.new(self, o, opts, fzf_win)
7-
setmetatable(self, M)
7+
function M.builtin:new(o, opts, fzf_win)
8+
self.super.new(self, o, opts, fzf_win)
9+
setmetatable(self, M.builtin)
810
return self
911
end
1012

11-
function M:populate_preview_buf(entry_str)
13+
function M.builtin:populate_preview_buf(entry_str)
1214
local entry = fzf.path.entry_to_file(entry_str, self.opts)
1315
local fname = fzf.path.tail(entry.path)
1416
local buf = self:get_tmp_buffer()
@@ -19,4 +21,16 @@ function M:populate_preview_buf(entry_str)
1921
self.win:update_preview_title(fname)
2022
end
2123

24+
function M.fzf:new(o, opts, fzf_win)
25+
self.super.new(self, o, opts, fzf_win)
26+
setmetatable(self, M.fzf)
27+
return self
28+
end
29+
30+
function M.fzf:cmdline(_)
31+
return fzf.shell.stringify_data(function(items, _, _)
32+
return items[1]
33+
end, self.opts, self.opts.field_index_expr or "{}")
34+
end
35+
2236
return M

lua/fzf-lua/win.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,10 @@ function FzfWin:generate_layout()
351351
row = pwopts.row + ph + pwopts.height
352352
end
353353
-- enlarge the height to align fzf with preview win
354-
width = width + math.max(pw - w, 0)
355-
pwopts.width = pwopts.width + math.max(w - pw, 0)
354+
if self.previewer_is_builtin then
355+
width = width + math.max(pw - w, 0)
356+
pwopts.width = pwopts.width + math.max(w - pw, 0)
357+
end
356358
else -- left|right
357359
pwopts.row = row
358360
pwopts.height = height
@@ -369,8 +371,10 @@ function FzfWin:generate_layout()
369371
col = pwopts.col + pw + pwopts.width
370372
end
371373
-- enlarge the height to align fzf with preview win
372-
height = height + math.max(ph - h, 0)
373-
pwopts.height = pwopts.height + math.max(h - ph, 0)
374+
if self.previewer_is_builtin then
375+
height = height + math.max(ph - h, 0)
376+
pwopts.height = pwopts.height + math.max(h - ph, 0)
377+
end
374378
end
375379
end
376380
self.layout = {

scripts/make_cli.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ if filter then
2424
filter_cases = function(case)
2525
local desc = vim.deepcopy(case.desc)
2626
table.remove(desc, 1)
27+
-- https://github.com/echasnovski/mini.nvim/blob/200df25c9f62d8b803a7aec6127abfc0c6f536ef/lua/mini/test.lua#L1960
28+
local args = vim.inspect(case.args, { newline = "", indent = "" })
29+
desc[#desc + 1] = args
30+
-- local ok, reg = pcall(vim.regex, filter)
31+
-- return ok and reg:match_str(table.concat(desc, " "))
2732
return table.concat(desc, " "):match(filter)
2833
end
2934
end

tests/files_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ T["files"]["previewer"]["builtin"] = new_set({ parametrize = { { "ci" }, { "buil
8282
winopts = { preview = { scrollbar = false } },
8383
previewer = previewer == "builtin"
8484
and "builtin"
85-
or function() return require("fzf-lua.test.previewer") end,
85+
or function() return require("fzf-lua.test.previewer").builtin end,
8686
__after_open = function()
8787
-- Verify previewer "last_entry" was set
8888
child.type_keys("<c-j>")
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--|---------|---------|---------|---------|---------|---------|----
2+
01|
3+
02|~
4+
03|~ ╭─────────────────────────────────────────────────╮
5+
04|~ │> 3/3 │
6+
05|~ │──────────────────────────────────────────────── │
7+
06|~ │▌ foo │
8+
07|~ │ bar │
9+
08|~ │ baz │
10+
09|~ │ │
11+
10|~ │ │
12+
11|~ │ │
13+
12|~ │ │
14+
13|~ │ │
15+
14|~ │ │
16+
15|~ │ │
17+
16|~ │ │
18+
17|~ │ │
19+
18|~ │ │
20+
19|~ │ │
21+
20|~ │ │
22+
21|~ │ │
23+
22|~ ╰─────────────────────────────────────────────────╯
24+
23|~
25+
24|[No Name] 0,0-1 All
26+
25|
27+
26|
28+
27|
29+
28|-- TERMINAL -- 1,3 All

tests/screenshots/tests-win_spec.lua---win---previewer---toggle_behavior=extend---1-+-args-{-{profile-=-'border-fused'}-}-002 renamed to tests/screenshots/tests-win_spec.lua---win---toggle------1-+-args-{-'B',-{profile-=-'border-fused'}-}-002

File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--|---------|---------|---------|---------|---------|---------|----
2+
01|
3+
02|~
4+
03|~
5+
04|~ > 3/3
6+
05|~ ────────────────────────────────────────────────
7+
06|~ ▌ foo
8+
07|~ bar
9+
08|~ baz
10+
09|~
11+
10|~
12+
11|~
13+
12|~
14+
13|~
15+
14|~
16+
15|~
17+
16|~
18+
17|~
19+
18|~
20+
19|~
21+
20|~
22+
21|~
23+
22|~
24+
23|~
25+
24|[No Name] 0,0-1 All
26+
25|
27+
26|
28+
27|
29+
28|-- TERMINAL -- 1,3 All

tests/screenshots/tests-win_spec.lua---win---previewer---toggle_behavior=extend---1-+-args-{-{profile-=-'borderless-full',winopts-=-{preview-=-{layout-=-'horizontal'}}}-}-002 renamed to tests/screenshots/tests-win_spec.lua---win---toggle------1-+-args-{-'B',-{profile-=-'borderless-full',winopts-=-{preview-=-{layout-=-'horizontal'}}}-}-002

File renamed without changes.

tests/screenshots/tests-win_spec.lua---win---previewer---toggle_behavior=extend---1-+-args-{-{winopts-=-{border-=-false}}-} renamed to tests/screenshots/tests-win_spec.lua---win---toggle------1-+-args-{-'B',-{winopts-=-{border-=-false}}-}

File renamed without changes.

tests/screenshots/tests-win_spec.lua---win---previewer---toggle_behavior=extend---1-+-args-{-{winopts-=-{border-=-false}}-}-002 renamed to tests/screenshots/tests-win_spec.lua---win---toggle------1-+-args-{-'B',-{winopts-=-{border-=-false}}-}-002

File renamed without changes.

0 commit comments

Comments
 (0)