From 5d37c3ea08f40d8c9d3a9ebcc72bd641d366c110 Mon Sep 17 00:00:00 2001 From: fdschmidt93 <39233597+fdschmidt93@users.noreply.github.com> Date: Wed, 1 Sep 2021 18:17:18 +0200 Subject: feat: allow caching and resuming picker (#1051) * expose `cache_picker` in telescope.setup to configure caching, see `:h telescope.defaults.cache_picker` * add builtin.resume and builtin.pickers picker --- lua/telescope/actions/init.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lua/telescope/actions/init.lua') diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua index cda5f1d..aa930dc 100644 --- a/lua/telescope/actions/init.lua +++ b/lua/telescope/actions/init.lua @@ -832,6 +832,21 @@ actions.cycle_previewers_prev = function(prompt_bufnr) actions.get_current_picker(prompt_bufnr):cycle_previewers(-1) end +--- Removes the selected picker in |builtin.pickers|.
+--- This action is not mapped by default and only intended for |builtin.pickers|. +---@param prompt_bufnr number: The prompt bufnr +actions.remove_selected_picker = function(prompt_bufnr) + local current_picker = action_state.get_current_picker(prompt_bufnr) + local selection_index = current_picker:get_index(current_picker:get_selection_row()) + local cached_pickers = state.get_global_key "cached_pickers" + current_picker:delete_selection(function() + table.remove(cached_pickers, selection_index) + end) + if #cached_pickers == 0 then + actions.close(prompt_bufnr) + end +end + -- ================================================== -- Transforms modules and sets the corect metatables. -- ================================================== -- cgit v1.2.3