1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-07 22:02:56 +03:00

feat: Implement range stash drop

Signed-off-by: gaogao-qwq <gaogaoqwq@gmail.com>
This commit is contained in:
gaogao-qwq
2025-04-02 16:08:24 +08:00
parent cd2286276c
commit 3a03aebd89
5 changed files with 65 additions and 9 deletions

View File

@@ -50,8 +50,8 @@ func (self *StashController) GetKeybindings(opts types.KeybindingsOpts) []*types
},
{
Key: opts.GetKey(opts.Config.Universal.Remove),
Handler: self.withItem(self.handleStashDrop),
GetDisabledReason: self.require(self.singleItemSelected()),
Handler: self.withItems(self.handleStashDrop),
GetDisabledReason: self.require(self.itemRangeSelected()),
Description: self.c.Tr.Drop,
Tooltip: self.c.Tr.StashDropTooltip,
DisplayOnScreen: true,
@@ -161,16 +161,19 @@ func (self *StashController) handleStashPop(stashEntry *models.StashEntry) error
return nil
}
func (self *StashController) handleStashDrop(stashEntry *models.StashEntry) error {
func (self *StashController) handleStashDrop(stashEntries []*models.StashEntry) error {
self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.StashDrop,
Prompt: self.c.Tr.SureDropStashEntry,
HandleConfirm: func() error {
self.c.LogAction(self.c.Tr.Actions.Stash)
err := self.c.Git().Stash.Drop(stashEntry.Index)
_ = self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH}})
if err != nil {
return err
startIndex := stashEntries[0].Index
for range stashEntries {
err := self.c.Git().Stash.Drop(startIndex)
_ = self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH}})
if err != nil {
return err
}
}
return nil
},