jesseduffield.lazygit/pkg/gui/controllers/search_controller.go
Stefan Haller c840013ca3 Remove error return value from functions that always return nil
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.
2026-08-31 20:41:22 +02:00

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
}