mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
Allow user to filter the files view to only show untracked files
This handles the situation where the user's own config says to not show untracked files, as is often the case with bare repos managing a user's dotfiles.
This commit is contained in:
@ -16,6 +16,7 @@ const (
|
||||
DisplayStaged
|
||||
DisplayUnstaged
|
||||
DisplayTracked
|
||||
DisplayUntracked
|
||||
// this shows files with merge conflicts
|
||||
DisplayConflicted
|
||||
)
|
||||
@ -40,6 +41,7 @@ type IFileTree interface {
|
||||
|
||||
FilterFiles(test func(*models.File) bool) []*models.File
|
||||
SetStatusFilter(filter FileTreeDisplayFilter)
|
||||
ForceShowUntracked() bool
|
||||
Get(index int) *FileNode
|
||||
GetFile(path string) *models.File
|
||||
GetAllItems() []*FileNode
|
||||
@ -87,6 +89,8 @@ func (self *FileTree) getFilesForDisplay() []*models.File {
|
||||
return self.FilterFiles(func(file *models.File) bool { return file.HasUnstagedChanges })
|
||||
case DisplayTracked:
|
||||
return self.FilterFiles(func(file *models.File) bool { return file.Tracked })
|
||||
case DisplayUntracked:
|
||||
return self.FilterFiles(func(file *models.File) bool { return !file.Tracked })
|
||||
case DisplayConflicted:
|
||||
return self.FilterFiles(func(file *models.File) bool { return file.HasMergeConflicts })
|
||||
default:
|
||||
@ -94,6 +98,10 @@ func (self *FileTree) getFilesForDisplay() []*models.File {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *FileTree) ForceShowUntracked() bool {
|
||||
return self.filter == DisplayUntracked
|
||||
}
|
||||
|
||||
func (self *FileTree) FilterFiles(test func(*models.File) bool) []*models.File {
|
||||
return lo.Filter(self.getFiles(), func(file *models.File, _ int) bool { return test(file) })
|
||||
}
|
||||
|
Reference in New Issue
Block a user