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

lots more generics

This commit is contained in:
Jesse Duffield
2022-03-19 15:36:46 +11:00
parent c7a629c440
commit eda8f4a5d4
19 changed files with 384 additions and 299 deletions

View File

@ -1,7 +1,7 @@
package controllers
import (
"github.com/jesseduffield/generics/list"
"github.com/jesseduffield/generics/slices"
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
@ -57,7 +57,7 @@ func (self *GlobalController) customCommand() error {
func (self *GlobalController) GetCustomCommandsHistorySuggestionsFunc() func(string) []*types.Suggestion {
// reversing so that we display the latest command first
history := list.Reverse(self.c.GetAppState().CustomCommandsHistory)
history := slices.Reverse(self.c.GetAppState().CustomCommandsHistory)
return helpers.FuzzySearchFunc(history)
}

View File

@ -2,6 +2,7 @@ package helpers
import (
"github.com/jesseduffield/generics/set"
"github.com/jesseduffield/generics/slices"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/context"
@ -118,12 +119,12 @@ func (self *CherryPickHelper) add(selectedCommit *models.Commit, commitsList []*
commitSet := self.CherryPickedCommitShaSet()
commitSet.Add(selectedCommit.Sha)
commitsInSet := lo.Filter(commitsList, func(commit *models.Commit, _ int) bool {
return commitSet.Includes(commit.Sha)
})
newCommits := lo.Map(commitsInSet, func(commit *models.Commit, _ int) *models.Commit {
return &models.Commit{Name: commit.Name, Sha: commit.Sha}
})
newCommits := slices.FilterThenMap(commitsList,
func(commit *models.Commit) bool { return commitSet.Includes(commit.Sha) },
func(commit *models.Commit) *models.Commit {
return &models.Commit{Name: commit.Name, Sha: commit.Sha}
},
)
self.getData().CherryPickedCommits = newCommits
}