1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

Implement state filtering for commit files

This commit is contained in:
Liberatys
2021-06-20 16:55:50 +02:00
committed by Jesse Duffield
parent bdea3b7dcf
commit 2dc6f5f079
7 changed files with 87 additions and 2 deletions

View File

@@ -473,6 +473,39 @@ func (gui *Gui) handleCommitEditorPress() error {
)
}
func (gui *Gui) handleStatusFilterPressed() error {
menuItems := []*menuItem{}
menuItems = append(menuItems, &menuItem{
displayString: "Show only staged files",
onPress: func() error {
return gui.setStatusFiltering(filetree.DisplayStaged)
},
})
menuItems = append(menuItems, &menuItem{
displayString: "Show only unstaged files",
onPress: func() error {
return gui.setStatusFiltering(filetree.DisplayUnstaged)
},
})
menuItems = append(menuItems, &menuItem{
displayString: "Reset Filter",
onPress: func() error {
return gui.setStatusFiltering(filetree.DisplayAll)
},
})
return gui.createMenu(gui.Tr.FilteringMenuTitle, menuItems, createMenuOptions{showCancel: false})
}
func (gui *Gui) setStatusFiltering(filter filetree.FileManagerDisplayFilter) error {
state := gui.State
state.FileManager.SetDisplayFilter(filter)
return gui.handleRefreshFiles()
}
func (gui *Gui) editFile(filename string) error {
return gui.editFileAtLine(filename, 1)
}