summaryrefslogtreecommitdiff
path: root/lua/telescope/actions/init.lua
diff options
context:
space:
mode:
authorfdschmidt93 <39233597+fdschmidt93@users.noreply.github.com>2021-09-01 18:17:18 +0200
committerGitHub <noreply@github.com>2021-09-01 18:17:18 +0200
commit5d37c3ea08f40d8c9d3a9ebcc72bd641d366c110 (patch)
treee66df8fe1312c38ad28ff64e0f0218b415bf18af /lua/telescope/actions/init.lua
parent67bc1dcdd6eea1915b7c397b7c02451bbdc277a0 (diff)
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
Diffstat (limited to 'lua/telescope/actions/init.lua')
-rw-r--r--lua/telescope/actions/init.lua15
1 files changed, 15 insertions, 0 deletions
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|.<br>
+--- 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.
-- ==================================================