summaryrefslogtreecommitdiff
path: root/lua/telescope/pickers.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/telescope/pickers.lua')
-rw-r--r--lua/telescope/pickers.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua
index 4cc1623..9397c57 100644
--- a/lua/telescope/pickers.lua
+++ b/lua/telescope/pickers.lua
@@ -693,7 +693,7 @@ end
---
--- Example usage in telescope:
--- - `actions.delete_buffer()`
----@param delete_cb function: called with each deleted selection
+---@param delete_cb function: called for each selection fn(s) -> bool|nil (true|nil removes the entry from the results)
function Picker:delete_selection(delete_cb)
vim.validate { delete_cb = { delete_cb, "f" } }
local original_selection_strategy = self.selection_strategy
@@ -719,8 +719,10 @@ function Picker:delete_selection(delete_cb)
return x > y
end)
for _, index in ipairs(selection_index) do
- local selection = table.remove(self.finder.results, index)
- delete_cb(selection)
+ local delete_cb_return = delete_cb(self.finder.results[index])
+ if delete_cb_return == nil or delete_cb_return == true then
+ table.remove(self.finder.results, index)
+ end
end
if used_multi_select then