mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 15:46:26 -04:00
Originally I thought we'd benefit from this change in this branch; turns out that we didn't after all, because we changed the approach, but it's a nice cleanup anyway, so we include it here.
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package controllers
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
)
|
|
|
|
type SearchControllerFactory struct {
|
|
c *ControllerCommon
|
|
}
|
|
|
|
func NewSearchControllerFactory(c *ControllerCommon) *SearchControllerFactory {
|
|
return &SearchControllerFactory{
|
|
c: c,
|
|
}
|
|
}
|
|
|
|
func (self *SearchControllerFactory) Create(context types.ISearchableContext) *SearchController {
|
|
return &SearchController{
|
|
baseController: baseController{},
|
|
c: self.c,
|
|
context: context,
|
|
}
|
|
}
|
|
|
|
type SearchController struct {
|
|
baseController
|
|
c *ControllerCommon
|
|
|
|
context types.ISearchableContext
|
|
}
|
|
|
|
func (self *SearchController) Context() types.Context {
|
|
return self.context
|
|
}
|
|
|
|
func (self *SearchController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding {
|
|
return []*types.Binding{
|
|
{
|
|
Keys: opts.GetKeys(opts.Config.Universal.StartSearch),
|
|
Handler: self.openSearchPrompt,
|
|
Description: self.c.Tr.StartSearch,
|
|
},
|
|
}
|
|
}
|
|
|
|
func (self *SearchController) openSearchPrompt() error {
|
|
self.c.Helpers().Search.OpenSearchPrompt(self.context)
|
|
return nil
|
|
}
|