1
1
package controllers
2
2
3
3
import (
4
+ "github.com/jesseduffield/lazygit/pkg/gui/context"
4
5
"github.com/jesseduffield/lazygit/pkg/gui/types"
5
6
)
6
7
7
8
type MainViewController struct {
8
9
baseController
9
10
c * ControllerCommon
10
11
11
- context types. Context
12
- otherContext types. Context
12
+ context * context. MainContext
13
+ otherContext * context. MainContext
13
14
}
14
15
15
16
var _ types.IController = & MainViewController {}
16
17
17
18
func NewMainViewController (
18
19
c * ControllerCommon ,
19
- context types. Context ,
20
- otherContext types. Context ,
20
+ context * context. MainContext ,
21
+ otherContext * context. MainContext ,
21
22
) * MainViewController {
22
23
return & MainViewController {
23
24
baseController : baseController {},
@@ -41,6 +42,13 @@ func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*ty
41
42
Handler : self .escape ,
42
43
Description : self .c .Tr .ExitFocusedMainView ,
43
44
},
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
+ },
44
52
}
45
53
}
46
54
@@ -61,3 +69,15 @@ func (self *MainViewController) escape() error {
61
69
self .c .Context ().Pop ()
62
70
return nil
63
71
}
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