1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

no more filterThenMap

This commit is contained in:
Jesse Duffield
2022-03-20 09:24:39 +11:00
parent 67a76523fb
commit e392b9f86a
2 changed files with 13 additions and 15 deletions

View File

@ -14,14 +14,13 @@ import (
) )
func (gui *Gui) popupViewNames() []string { func (gui *Gui) popupViewNames() []string {
return slices.FilterThenMap(gui.State.Contexts.Flatten(), popups := slices.Filter(gui.State.Contexts.Flatten(), func(c types.Context) bool {
func(c types.Context) bool { return c.GetKind() == types.PERSISTENT_POPUP || c.GetKind() == types.TEMPORARY_POPUP
return c.GetKind() == types.PERSISTENT_POPUP || c.GetKind() == types.TEMPORARY_POPUP })
},
func(c types.Context) string { return slices.Map(popups, func(c types.Context) string {
return c.GetViewName() return c.GetViewName()
}, })
)
} }
func (gui *Gui) currentContextKeyIgnoringPopups() types.ContextKey { func (gui *Gui) currentContextKeyIgnoringPopups() types.ContextKey {

View File

@ -118,14 +118,13 @@ func (self *CherryPickHelper) add(selectedCommit *models.Commit, commitsList []*
commitSet := self.CherryPickedCommitShaSet() commitSet := self.CherryPickedCommitShaSet()
commitSet.Add(selectedCommit.Sha) commitSet.Add(selectedCommit.Sha)
newCommits := slices.FilterThenMap(commitsList, cherryPickedCommits := slices.Filter(commitsList, func(commit *models.Commit) bool {
func(commit *models.Commit) bool { return commitSet.Includes(commit.Sha) }, return commitSet.Includes(commit.Sha)
func(commit *models.Commit) *models.Commit { })
return &models.Commit{Name: commit.Name, Sha: commit.Sha}
},
)
self.getData().CherryPickedCommits = newCommits self.getData().CherryPickedCommits = slices.Map(cherryPickedCommits, func(commit *models.Commit) *models.Commit {
return &models.Commit{Name: commit.Name, Sha: commit.Sha}
})
} }
// you can only copy from one context at a time, because the order and position of commits matter // you can only copy from one context at a time, because the order and position of commits matter