mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-10-29 15:09:22 +03:00
Fix dropping a range of stashes in filtered mode
To fix the problem described in the previous commit, iterate backwards over the stashes that we want to delete. This allows us to use their Index field.
This commit is contained in:
@@ -161,9 +161,8 @@ func (self *StashController) handleStashDrop(stashEntries []*models.StashEntry)
|
|||||||
Prompt: self.c.Tr.SureDropStashEntry,
|
Prompt: self.c.Tr.SureDropStashEntry,
|
||||||
HandleConfirm: func() error {
|
HandleConfirm: func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.Stash)
|
self.c.LogAction(self.c.Tr.Actions.Stash)
|
||||||
startIndex := stashEntries[0].Index
|
for i := len(stashEntries) - 1; i >= 0; i-- {
|
||||||
for range stashEntries {
|
err := self.c.Git().Stash.Drop(stashEntries[i].Index)
|
||||||
err := self.c.Git().Stash.Drop(startIndex)
|
|
||||||
self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH}})
|
self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -58,24 +58,14 @@ var DropMultipleInFilteredMode = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Content(Contains("Are you sure you want to drop the selected stash entry(ies)?")).
|
Content(Contains("Are you sure you want to drop the selected stash entry(ies)?")).
|
||||||
Confirm()
|
Confirm()
|
||||||
}).
|
}).
|
||||||
/* EXPECTED:
|
|
||||||
IsEmpty()
|
IsEmpty()
|
||||||
ACTUAL: */
|
|
||||||
Lines(
|
|
||||||
Contains("stash two-a"),
|
|
||||||
)
|
|
||||||
|
|
||||||
t.GlobalPress(keys.Universal.Return) // cancel filtering mode
|
t.GlobalPress(keys.Universal.Return) // cancel filtering mode
|
||||||
t.Views().Stash().
|
t.Views().Stash().
|
||||||
Lines(
|
Lines(
|
||||||
/* EXPECTED:
|
|
||||||
Contains("stash four"),
|
Contains("stash four"),
|
||||||
Contains("stash three"),
|
Contains("stash three"),
|
||||||
Contains("stash one"),
|
Contains("stash one"),
|
||||||
ACTUAL: */
|
|
||||||
Contains("stash four"),
|
|
||||||
Contains("stash two-a"),
|
|
||||||
Contains("stash one"),
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user