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 <ian.liu@tupl.com>
This commit is contained in:
Ian Liu 2025-02-05 13:02:12 -08:00 committed by GitHub
parent 398c2cb7ff
commit 337a3ae7ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -350,14 +350,18 @@ function M.git_branch_del(picker, item)
return
end
-- Proceed with deletion
Snacks.picker.util.cmd({ "git", "branch", "-d", branch }, function()
Snacks.notify("Deleted Branch `" .. branch .. "`", { title = "Snacks Picker" })
vim.cmd.checktime()
picker.list:set_selected()
picker.list:set_target()
picker:find()
end, { cwd = picker:cwd() })
Snacks.picker.select({ "Yes", "No" }, { prompt = ("Delete branch %q?"):format(branch) }, function(_, idx)
if idx == 1 then
-- Proceed with deletion
Snacks.picker.util.cmd({ "git", "branch", "-d", branch }, function()
Snacks.notify("Deleted Branch `" .. branch .. "`", { title = "Snacks Picker" })
vim.cmd.checktime()
picker.list:set_selected()
picker.list:set_target()
picker:find()
end, { cwd = picker:cwd() })
end
end)
end, { cwd = picker:cwd() })
end