mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-31 23:19:40 +02:00
Show filter state in top right corner of Files panel frame
This includes the "only conflicting" status that the user can't switch to themselves. We display it anyway to give a hint that files are being filtered, and to let them know that they can turn the filter off if they want to.
This commit is contained in:
parent
2f4cedd025
commit
aad2622278
@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
@ -801,10 +802,30 @@ func (self *FilesController) handleStatusFilterPressed() error {
|
||||
})
|
||||
}
|
||||
|
||||
func (self *FilesController) filteringLabel(filter filetree.FileTreeDisplayFilter) string {
|
||||
switch filter {
|
||||
case filetree.DisplayAll:
|
||||
return ""
|
||||
case filetree.DisplayStaged:
|
||||
return self.c.Tr.FilterLabelStagedFiles
|
||||
case filetree.DisplayUnstaged:
|
||||
return self.c.Tr.FilterLabelUnstagedFiles
|
||||
case filetree.DisplayTracked:
|
||||
return self.c.Tr.FilterLabelTrackedFiles
|
||||
case filetree.DisplayUntracked:
|
||||
return self.c.Tr.FilterLabelUntrackedFiles
|
||||
case filetree.DisplayConflicted:
|
||||
return self.c.Tr.FilterLabelConflictingFiles
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("Unexpected files display filter: %d", filter))
|
||||
}
|
||||
|
||||
func (self *FilesController) setStatusFiltering(filter filetree.FileTreeDisplayFilter) error {
|
||||
previousFilter := self.context().GetFilter()
|
||||
|
||||
self.context().FileTreeViewModel.SetStatusFilter(filter)
|
||||
self.c.Contexts().Files.GetView().Subtitle = self.filteringLabel(filter)
|
||||
|
||||
// Whenever we switch between untracked and other filters, we need to refresh the files view
|
||||
// because the untracked files filter applies when running `git status`.
|
||||
|
@ -591,9 +591,11 @@ func (self *RefreshHelper) refreshStateFiles() error {
|
||||
if conflictFileCount > 0 && prevConflictFileCount == 0 {
|
||||
if fileTreeViewModel.GetFilter() == filetree.DisplayAll {
|
||||
fileTreeViewModel.SetStatusFilter(filetree.DisplayConflicted)
|
||||
self.c.Contexts().Files.GetView().Subtitle = self.c.Tr.FilterLabelConflictingFiles
|
||||
}
|
||||
} else if conflictFileCount == 0 && fileTreeViewModel.GetFilter() == filetree.DisplayConflicted {
|
||||
fileTreeViewModel.SetStatusFilter(filetree.DisplayAll)
|
||||
self.c.Contexts().Files.GetView().Subtitle = ""
|
||||
}
|
||||
|
||||
self.c.Model().Files = files
|
||||
|
@ -90,6 +90,11 @@ type TranslationSet struct {
|
||||
FilterTrackedFiles string
|
||||
FilterUntrackedFiles string
|
||||
NoFilter string
|
||||
FilterLabelStagedFiles string
|
||||
FilterLabelUnstagedFiles string
|
||||
FilterLabelTrackedFiles string
|
||||
FilterLabelUntrackedFiles string
|
||||
FilterLabelConflictingFiles string
|
||||
MergeConflictsTitle string
|
||||
Checkout string
|
||||
CheckoutTooltip string
|
||||
@ -1116,6 +1121,11 @@ func EnglishTranslationSet() *TranslationSet {
|
||||
FilterTrackedFiles: "Show only tracked files",
|
||||
FilterUntrackedFiles: "Show only untracked files",
|
||||
NoFilter: "No filter",
|
||||
FilterLabelStagedFiles: "(only staged)",
|
||||
FilterLabelUnstagedFiles: "(only unstaged)",
|
||||
FilterLabelTrackedFiles: "(only tracked)",
|
||||
FilterLabelUntrackedFiles: "(only untracked)",
|
||||
FilterLabelConflictingFiles: "(only conflicting)",
|
||||
NoChangedFiles: "No changed files",
|
||||
SoftReset: "Soft reset",
|
||||
AlreadyCheckedOutBranch: "You have already checked out this branch",
|
||||
|
Loading…
x
Reference in New Issue
Block a user