1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

Introduce filtered list view model

We're going to start supporting filtering of list views
This commit is contained in:
Jesse Duffield
2023-05-27 14:14:43 +10:00
parent fd861826bc
commit a9e2c8129f
43 changed files with 798 additions and 232 deletions

View File

@@ -7,21 +7,26 @@ import (
)
type SubmodulesContext struct {
*BasicViewModel[*models.SubmoduleConfig]
*FilteredListViewModel[*models.SubmoduleConfig]
*ListContextTrait
}
var _ types.IListContext = (*SubmodulesContext)(nil)
func NewSubmodulesContext(c *ContextCommon) *SubmodulesContext {
viewModel := NewBasicViewModel(func() []*models.SubmoduleConfig { return c.Model().Submodules })
viewModel := NewFilteredListViewModel(
func() []*models.SubmoduleConfig { return c.Model().Submodules },
func(submodule *models.SubmoduleConfig) []string {
return []string{submodule.Name}
},
)
getDisplayStrings := func(startIdx int, length int) [][]string {
return presentation.GetSubmoduleListDisplayStrings(c.Model().Submodules)
return presentation.GetSubmoduleListDisplayStrings(viewModel.GetItems())
}
return &SubmodulesContext{
BasicViewModel: viewModel,
FilteredListViewModel: viewModel,
ListContextTrait: &ListContextTrait{
Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
View: c.Views().Submodules,