Skip to content

Commit bf419ab

Browse files
committed
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.
1 parent ef3e899 commit bf419ab

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

pkg/gui/controllers/stash_controller.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,8 @@ func (self *StashController) handleStashDrop(stashEntries []*models.StashEntry)
161161
Prompt: self.c.Tr.SureDropStashEntry,
162162
HandleConfirm: func() error {
163163
self.c.LogAction(self.c.Tr.Actions.Stash)
164-
startIndex := stashEntries[0].Index
165-
for range stashEntries {
166-
err := self.c.Git().Stash.Drop(startIndex)
164+
for i := len(stashEntries) - 1; i >= 0; i-- {
165+
err := self.c.Git().Stash.Drop(stashEntries[i].Index)
167166
self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH}})
168167
if err != nil {
169168
return err

pkg/integration/tests/stash/drop_multiple_in_filtered_mode.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,14 @@ var DropMultipleInFilteredMode = NewIntegrationTest(NewIntegrationTestArgs{
5858
Content(Contains("Are you sure you want to drop the selected stash entry(ies)?")).
5959
Confirm()
6060
}).
61-
/* EXPECTED:
6261
IsEmpty()
63-
ACTUAL: */
64-
Lines(
65-
Contains("stash two-a"),
66-
)
6762

6863
t.GlobalPress(keys.Universal.Return) // cancel filtering mode
6964
t.Views().Stash().
7065
Lines(
71-
/* EXPECTED:
7266
Contains("stash four"),
7367
Contains("stash three"),
7468
Contains("stash one"),
75-
ACTUAL: */
76-
Contains("stash four"),
77-
Contains("stash two-a"),
78-
Contains("stash one"),
7969
)
8070
},
8171
})

0 commit comments

Comments
 (0)