Skip to content

Commit

Permalink
added resume support for 'vim.ui.select'
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Jan 18, 2022
1 parent 5b52706 commit 8e37ef6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lua/fzf-lua/providers/ui_select.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local core = require "fzf-lua.core"
local utils = require "fzf-lua.utils"
local actions = require "fzf-lua.actions"

local M = {}

Expand Down Expand Up @@ -69,10 +70,22 @@ M.ui_select = function(items, opts, on_choice)
['--preview-window'] = 'hidden:right:0',
}

_opts.actions = vim.tbl_deep_extend("keep", _opts.actions or {},
{
["default"] = function(selected, _)
local idx = selected and tonumber(selected[1]:match("^(%d+).")) or nil
on_choice(idx and items[idx] or nil, idx)
end
})

core.fzf_wrap(_opts, entries, function(selected)

local idx = selected and tonumber(selected[1]:match("^(%d+).")) or nil
on_choice(idx and items[idx] or nil, idx)
if not selected then
on_choice(nil, nil)
return
end

actions.act(_opts.actions, selected)

end)()

Expand Down

0 comments on commit 8e37ef6

Please sign in to comment.