Skip to content

Commit 8350756

Browse files
committed
Add deletion confirmation in telescope extension
1 parent 9eeb8ea commit 8350756

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lua/telescope/_extensions/git_worktree.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,28 @@ local create_delete_failure_handler = function(prompt_bufnr)
4848
end
4949
end
5050

51+
local confirm_deletion = function()
52+
if not git_worktree._config.confirm_telescope_deletions then
53+
return true
54+
end
55+
56+
local confirmation = vim.fn.input(
57+
string.format("Delete worktree? [y/n]: ")
58+
)
59+
60+
if string.sub(string.lower(confirmation), 0, 1) == "y" then
61+
return true
62+
end
63+
64+
print("Didn't delete worktree")
65+
return false
66+
end
67+
5168
delete_worktree = function(prompt_bufnr, force)
69+
if not confirm_deletion() then
70+
return
71+
end
72+
5273
local worktree_path = get_worktree_path(prompt_bufnr)
5374
actions.close(prompt_bufnr)
5475
if worktree_path ~= nil then

0 commit comments

Comments
 (0)