Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pkg/gui/controllers/stash_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ func (self *StashController) handleStashDrop(stashEntries []*models.StashEntry)
Prompt: self.c.Tr.SureDropStashEntry,
HandleConfirm: func() error {
self.c.LogAction(self.c.Tr.Actions.Stash)
startIndex := stashEntries[0].Index
for range stashEntries {
err := self.c.Git().Stash.Drop(startIndex)
for i := len(stashEntries) - 1; i >= 0; i-- {
err := self.c.Git().Stash.Drop(stashEntries[i].Index)
self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH}})
if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion pkg/integration/tests/stash/drop_multiple.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ var DropMultiple = NewIntegrationTest(NewIntegrationTestArgs{
Contains("stash two"),
Contains("stash one"),
).
Press(keys.Universal.ToggleRangeSelect).
Press(keys.Universal.RangeSelectDown).
Press(keys.Universal.Remove).
Tap(func() {
Expand Down
71 changes: 71 additions & 0 deletions pkg/integration/tests/stash/drop_multiple_in_filtered_mode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package stash

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var DropMultipleInFilteredMode = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Drop multiple stash entries when filtering by path",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("initial commit")
shell.CreateFileAndAdd("file1", "content1")
shell.Stash("stash one")
shell.CreateFileAndAdd("file2", "content2a")
shell.Stash("stash two-a")
shell.CreateFileAndAdd("file3", "content3")
shell.Stash("stash three")
shell.CreateFileAndAdd("file2", "content2b")
shell.Stash("stash two-b")
shell.CreateFileAndAdd("file4", "content4")
shell.Stash("stash four")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Stash().
Lines(
Contains("stash four"),
Contains("stash two-b"),
Contains("stash three"),
Contains("stash two-a"),
Contains("stash one"),
)

t.GlobalPress(keys.Universal.FilteringMenu)
t.ExpectPopup().Menu().
Title(Equals("Filtering")).
Select(Contains("Enter path to filter by")).
Confirm()

t.ExpectPopup().Prompt().
Title(Equals("Enter path:")).
Type("file2").
Confirm()

t.Views().Stash().
Focus().
Lines(
Contains("stash two-b").IsSelected(),
Contains("stash two-a"),
).
Press(keys.Universal.RangeSelectDown).
Press(keys.Universal.Remove).
Tap(func() {
t.ExpectPopup().Confirmation().
Title(Equals("Stash drop")).
Content(Contains("Are you sure you want to drop the selected stash entry(ies)?")).
Confirm()
}).
IsEmpty()

t.GlobalPress(keys.Universal.Return) // cancel filtering mode
t.Views().Stash().
Lines(
Contains("stash four"),
Contains("stash three"),
Contains("stash one"),
)
},
})
1 change: 1 addition & 0 deletions pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ var tests = []*components.IntegrationTest{
stash.CreateBranch,
stash.Drop,
stash.DropMultiple,
stash.DropMultipleInFilteredMode,
stash.FilterByPath,
stash.Pop,
stash.PreventDiscardingFileChanges,
Expand Down
Loading