1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package gui
import (
"fmt"
"strings"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
func (gui *Gui) handleCreateFilteringMenuPanel() error {
fileName := ""
switch gui.currentSideListContext() {
case gui.State.Contexts.Files:
node := gui.getSelectedFileNode()
if node != nil {
fileName = node.GetPath()
}
case gui.State.Contexts.CommitFiles:
node := gui.State.Contexts.CommitFiles.GetSelectedFileNode()
if node != nil {
fileName = node.GetPath()
}
}
menuItems := []*types.MenuItem{}
if fileName != "" {
menuItems = append(menuItems, &types.MenuItem{
DisplayString: fmt.Sprintf("%s '%s'", gui.c.Tr.LcFilterBy, fileName),
OnPress: func() error {
return gui.setFiltering(fileName)
},
})
}
menuItems = append(menuItems, &types.MenuItem{
DisplayString: gui.c.Tr.LcFilterPathOption,
OnPress: func() error {
return gui.c.Prompt(types.PromptOpts{
FindSuggestionsFunc: gui.helpers.Suggestions.GetFilePathSuggestionsFunc(),
Title: gui.c.Tr.EnterFileName,
HandleConfirm: func(response string) error {
return gui.setFiltering(strings.TrimSpace(response))
},
})
},
})
if gui.State.Modes.Filtering.Active() {
menuItems = append(menuItems, &types.MenuItem{
DisplayString: gui.c.Tr.LcExitFilterMode,
OnPress: gui.clearFiltering,
})
}
return gui.c.Menu(types.CreateMenuOptions{Title: gui.c.Tr.FilteringMenuTitle, Items: menuItems})
}
|