Skip to content

Commit 337a3ae

Browse files
IanLiuTWIan Liu
and
Ian Liu
authored
feat(picker.git): add confirmation before deleting a git branch (#951)
## Description A minor update to add a confirmation dialogue before deleting a branch in `git_branches`. ## Related Issue(s) <!-- If this PR fixes any issues, please link to the issue here. - Fixes #<issue_number> --> ## Screenshots <!-- Add screenshots of the changes if applicable. --> --------- Co-authored-by: Ian Liu <[email protected]>
1 parent 398c2cb commit 337a3ae

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lua/snacks/picker/actions.lua

+12-8
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,18 @@ function M.git_branch_del(picker, item)
350350
return
351351
end
352352

353-
-- Proceed with deletion
354-
Snacks.picker.util.cmd({ "git", "branch", "-d", branch }, function()
355-
Snacks.notify("Deleted Branch `" .. branch .. "`", { title = "Snacks Picker" })
356-
vim.cmd.checktime()
357-
picker.list:set_selected()
358-
picker.list:set_target()
359-
picker:find()
360-
end, { cwd = picker:cwd() })
353+
Snacks.picker.select({ "Yes", "No" }, { prompt = ("Delete branch %q?"):format(branch) }, function(_, idx)
354+
if idx == 1 then
355+
-- Proceed with deletion
356+
Snacks.picker.util.cmd({ "git", "branch", "-d", branch }, function()
357+
Snacks.notify("Deleted Branch `" .. branch .. "`", { title = "Snacks Picker" })
358+
vim.cmd.checktime()
359+
picker.list:set_selected()
360+
picker.list:set_target()
361+
picker:find()
362+
end, { cwd = picker:cwd() })
363+
end
364+
end)
361365
end, { cwd = picker:cwd() })
362366
end
363367

0 commit comments

Comments
 (0)