diff options
Diffstat (limited to 'pkg/gui/context/suggestions_context.go')
-rw-r--r-- | pkg/gui/context/suggestions_context.go | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/pkg/gui/context/suggestions_context.go b/pkg/gui/context/suggestions_context.go index 6c565eedf..1291b37c8 100644 --- a/pkg/gui/context/suggestions_context.go +++ b/pkg/gui/context/suggestions_context.go @@ -2,12 +2,11 @@ package context import ( "github.com/jesseduffield/gocui" - "github.com/jesseduffield/lazygit/pkg/gui/context/traits" "github.com/jesseduffield/lazygit/pkg/gui/types" ) type SuggestionsContext struct { - *SuggestionsViewModel + *BasicViewModel[*types.Suggestion] *ListContextTrait } @@ -24,10 +23,10 @@ func NewSuggestionsContext( c *types.HelperCommon, ) *SuggestionsContext { - viewModel := NewSuggestionsViewModel(getModel) + viewModel := NewBasicViewModel(getModel) return &SuggestionsContext{ - SuggestionsViewModel: viewModel, + BasicViewModel: viewModel, ListContextTrait: &ListContextTrait{ Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{ ViewName: "suggestions", @@ -56,30 +55,3 @@ func (self *SuggestionsContext) GetSelectedItemId() string { return item.Value } - -type SuggestionsViewModel struct { - *traits.ListCursor - getModel func() []*types.Suggestion -} - -func NewSuggestionsViewModel(getModel func() []*types.Suggestion) *SuggestionsViewModel { - self := &SuggestionsViewModel{ - getModel: getModel, - } - - self.ListCursor = traits.NewListCursor(self) - - return self -} - -func (self *SuggestionsViewModel) GetItemsLength() int { - return len(self.getModel()) -} - -func (self *SuggestionsViewModel) GetSelected() *types.Suggestion { - if self.GetItemsLength() == 0 { - return nil - } - - return self.getModel()[self.GetSelectedLineIdx()] -} |