Merge pull request #67 from ibhagwan/master

chore(fzf-lua): use newer 'fzf_exec' API (#64)
This commit is contained in:
Steven Arcangeli 2022-09-20 20:28:26 +02:00 committed by GitHub
commit facb229f63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 11 deletions

View File

@ -16,18 +16,22 @@ M.select = function(config, items, opts, on_choice)
["--no-multi"] = "",
["--preview-window"] = "hidden:right:0",
},
actions = {
-- "default" gets called when pressing "enter"
-- all fzf style binds (i.e. "ctrl-y") are valid
["default"] = function(selected, _)
if not selected then
on_choice(nil, nil)
else
local label = selected[1]
local lnum = tonumber(label:match("^(%d+):"))
local item = items[lnum]
on_choice(item, lnum)
end
end
}
})
fzf.fzf_wrap(fzf_opts, labels, function(selected)
if not selected then
on_choice(nil, nil)
else
local label = selected[1]
local colon = string.find(label, ":")
local lnum = tonumber(string.sub(label, 1, colon - 1))
local item = items[lnum]
on_choice(item, lnum)
end
end)()
fzf.fzf_exec(labels, fzf_opts)
end
return M