Skip to content

Commit 1bcac02

Browse files
committed
fix(combine): regrression from recent refactors
1 parent 0fd8488 commit 1bcac02

1 file changed

Lines changed: 38 additions & 34 deletions

File tree

lua/fzf-lua/providers/meta.lua

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -101,46 +101,50 @@ end
101101

102102
M.combine = function(t)
103103
t = t or {}
104-
t.pickers = type(t.pickers) == "table" and type(t.pickers)
104+
105+
local pickers = type(t.pickers) == "table" and type(t.pickers)
105106
or type(t.pickers) == "string" and utils.strsplit(t.pickers, "[,;]")
106107
or nil
107108

108-
-- First picker options set the tone
109-
local opts1 = (function()
110-
if t.pickers and t.pickers[1] then
111-
local ok, opts = pcall(config.normalize_opts, t, t.pickers[1])
112-
return ok and opts
113-
end
114-
end)()
115-
if not opts1 then
116-
utils.warn("Must specify at least one valid picker")
117-
return
118-
end
109+
local opts = t
110+
t.pickers = nil
119111

120-
-- Let fzf_wrap know to NOT start the coroutine
121-
opts1._start = false
122-
123-
local cmds, opts = (function()
124-
local ret, opts = {}, nil
125-
for _, p in ipairs(t.pickers --[[@as table]]) do
126-
-- local ok, msg, cmd, o = pcall(FzfLua[p], opts1)
127-
-- if not ok or not cmd then
128-
local _, cmd, o = FzfLua[p](opts1)
129-
if not cmd or not o then
130-
utils.error("Error loading picker '%s', ignoring.", p)
131-
else
132-
table.insert(ret, cmd)
133-
-- NOTE: we use the [first picker] modified opts after picker setup
134-
-- as pickers can modify opts / add important parts
135-
if not opts then opts = o end
112+
-- Tells fzf_wrap to not start the fzf process
113+
opts._start = false
114+
115+
local cmds = {}
116+
local opts_copy = vim.deepcopy(opts)
117+
for i, name in ipairs(pickers) do
118+
if FzfLua[name] then
119+
local def
120+
local function gen_def(n, o)
121+
local wrapped = { FzfLua[n](o) }
122+
return {
123+
name = n,
124+
opts = wrapped[3],
125+
contents = wrapped[2],
126+
}
136127
end
128+
-- Default picker opts set the tone for this picker options
129+
-- this way convert reload / exec_silent actions will use a consistent
130+
-- opts ref in the callbacks so we can later modify internal values
131+
def = gen_def(name, i == 1 and opts or opts_copy)
132+
if i == 1 then
133+
-- Override opts with the modified return opts and remove start suppression
134+
opts = def.opts
135+
opts._start = nil
136+
end
137+
-- Instantiate the previewer, nil check as opts isn't guaranteed if the
138+
-- picker isn't avilable, e.g. `tags` when no tags file exists
139+
if def.opts and def.opts.previewer then
140+
def.previewer = require("fzf-lua.previewer").new(def.opts.previewer, def.opts)
141+
end
142+
-- Add content (shell command) to cmd array
143+
table.insert(cmds, def.contents)
144+
else
145+
utils.warn("invalid picker '%s', ignoring.", name)
137146
end
138-
return ret, opts
139-
end)()
140-
if not opts then return end
141-
142-
-- Let fzf_wrap know to START the coroutine
143-
opts._start = nil
147+
end
144148

145149
-- _G.dump(cmds)
146150
local contents = table.concat(cmds, utils.__IS_WINDOWS and "&" or ";")

0 commit comments

Comments
 (0)