Skip to content

Commit 6a3f583

Browse files
committed
Read all lines from task when starting to search
1 parent 95b2153 commit 6a3f583

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

pkg/gui/controllers/main_view_controller.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
package controllers
22

33
import (
4+
"github.com/jesseduffield/lazygit/pkg/gui/context"
45
"github.com/jesseduffield/lazygit/pkg/gui/types"
56
)
67

78
type MainViewController struct {
89
baseController
910
c *ControllerCommon
1011

11-
context types.Context
12-
otherContext types.Context
12+
context *context.MainContext
13+
otherContext *context.MainContext
1314
}
1415

1516
var _ types.IController = &MainViewController{}
1617

1718
func NewMainViewController(
1819
c *ControllerCommon,
19-
context types.Context,
20-
otherContext types.Context,
20+
context *context.MainContext,
21+
otherContext *context.MainContext,
2122
) *MainViewController {
2223
return &MainViewController{
2324
baseController: baseController{},
@@ -41,6 +42,13 @@ func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*ty
4142
Handler: self.escape,
4243
Description: self.c.Tr.ExitFocusedMainView,
4344
},
45+
{
46+
// overriding this because we want to read all of the task's output before we start searching
47+
Key: opts.GetKey(opts.Config.Universal.StartSearch),
48+
Handler: self.openSearch,
49+
Description: self.c.Tr.StartSearch,
50+
Tag: "navigation",
51+
},
4452
}
4553
}
4654

@@ -61,3 +69,15 @@ func (self *MainViewController) escape() error {
6169
self.c.Context().Pop()
6270
return nil
6371
}
72+
73+
func (self *MainViewController) openSearch() error {
74+
if manager := self.c.GetViewBufferManagerForView(self.context.GetView()); manager != nil {
75+
manager.ReadToEnd(func() {
76+
self.c.OnUIThread(func() error {
77+
return self.c.Helpers().Search.OpenSearchPrompt(self.context)
78+
})
79+
})
80+
}
81+
82+
return nil
83+
}

0 commit comments

Comments
 (0)