mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-23 22:24:51 +02:00
Make the main view searchable
This commit is contained in:
@@ -7,12 +7,16 @@ import (
|
||||
|
||||
type MainContext struct {
|
||||
*SimpleContext
|
||||
*SearchTrait
|
||||
}
|
||||
|
||||
var _ types.ISearchableContext = (*MainContext)(nil)
|
||||
|
||||
func NewMainContext(
|
||||
view *gocui.View,
|
||||
windowName string,
|
||||
key types.ContextKey,
|
||||
c *ContextCommon,
|
||||
) *MainContext {
|
||||
ctx := &MainContext{
|
||||
SimpleContext: NewSimpleContext(
|
||||
@@ -24,7 +28,14 @@ func NewMainContext(
|
||||
Focusable: true,
|
||||
HighlightOnFocus: false,
|
||||
})),
|
||||
SearchTrait: NewSearchTrait(c),
|
||||
}
|
||||
|
||||
ctx.GetView().SetOnSelectItem(ctx.SearchTrait.onSelectItemWrapper(func(int) error { return nil }))
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
||||
func (self *MainContext) ModelSearchResults(searchStr string, caseSensitive bool) []gocui.SearchPosition {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ func NewContextTree(c *ContextCommon) *ContextTree {
|
||||
Tags: NewTagsContext(c),
|
||||
Stash: NewStashContext(c),
|
||||
Suggestions: NewSuggestionsContext(c),
|
||||
Normal: NewMainContext(c.Views().Main, "main", NORMAL_MAIN_CONTEXT_KEY),
|
||||
NormalSecondary: NewMainContext(c.Views().Secondary, "secondary", NORMAL_SECONDARY_CONTEXT_KEY),
|
||||
Normal: NewMainContext(c.Views().Main, "main", NORMAL_MAIN_CONTEXT_KEY, c),
|
||||
NormalSecondary: NewMainContext(c.Views().Secondary, "secondary", NORMAL_SECONDARY_CONTEXT_KEY, c),
|
||||
Staging: NewPatchExplorerContext(
|
||||
c.Views().Staging,
|
||||
"main",
|
||||
|
||||
@@ -44,6 +44,9 @@ func (self *SwitchToFocusedMainViewController) Context() types.Context {
|
||||
func (self *SwitchToFocusedMainViewController) handleFocusMainView() error {
|
||||
mainViewContext := self.c.Helpers().Window.GetContextForWindow("main")
|
||||
mainViewContext.SetParentContext(self.context)
|
||||
if context, ok := mainViewContext.(types.ISearchableContext); ok {
|
||||
context.ClearSearchString()
|
||||
}
|
||||
self.c.Context().Push(mainViewContext, types.OnFocusOpts{})
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user