From 338064ac2cc4b5a6dc0f5b32cd08b4baceb421af Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 3 Apr 2025 17:18:57 +0200 Subject: [PATCH] Read all lines from task when starting to search --- pkg/gui/controllers/main_view_controller.go | 28 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/pkg/gui/controllers/main_view_controller.go b/pkg/gui/controllers/main_view_controller.go index e09cb27c0..b48868677 100644 --- a/pkg/gui/controllers/main_view_controller.go +++ b/pkg/gui/controllers/main_view_controller.go @@ -1,6 +1,7 @@ package controllers import ( + "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) @@ -8,16 +9,16 @@ type MainViewController struct { baseController c *ControllerCommon - context types.Context - otherContext types.Context + context *context.MainContext + otherContext *context.MainContext } var _ types.IController = &MainViewController{} func NewMainViewController( c *ControllerCommon, - context types.Context, - otherContext types.Context, + context *context.MainContext, + otherContext *context.MainContext, ) *MainViewController { return &MainViewController{ baseController: baseController{}, @@ -41,6 +42,13 @@ func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*ty Handler: self.escape, Description: self.c.Tr.ExitFocusedMainView, }, + { + // overriding this because we want to read all of the task's output before we start searching + Key: opts.GetKey(opts.Config.Universal.StartSearch), + Handler: self.openSearch, + Description: self.c.Tr.StartSearch, + Tag: "navigation", + }, } } @@ -61,3 +69,15 @@ func (self *MainViewController) escape() error { self.c.Context().Pop() return nil } + +func (self *MainViewController) openSearch() error { + if manager := self.c.GetViewBufferManagerForView(self.context.GetView()); manager != nil { + manager.ReadToEnd(func() { + self.c.OnUIThread(func() error { + return self.c.Helpers().Search.OpenSearchPrompt(self.context) + }) + }) + } + + return nil +}