From e883f74f3c285bb44217e3fdd455d8cfa1bfbe45 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 1 Feb 2025 18:40:17 +0100 Subject: [PATCH] Allow user to switch filter when showing only conflicts We don't need to maintain additional state to allow this; all we need to do is take over the filter only when the number of conflicting files goes from zero to non-zero, rather than every time it is non-zero. The only problem is that we don't allow users to go back to showing only conflicted files, but that's just because we don't have that as an entry in the menu. And I don't think it's a problem. --- pkg/gui/controllers/helpers/refresh_helper.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 37e451895..645435078 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -588,15 +588,11 @@ func (self *RefreshHelper) refreshStateFiles() error { fileTreeViewModel.RWMutex.Lock() // only taking over the filter if it hasn't already been set by the user. - // Though this does make it impossible for the user to actually say they want to display all if - // conflicts are currently being shown. Hmm. Worth it I reckon. If we need to add some - // extra state here to see if the user's set the filter themselves we can do that, but - // I'd prefer to maintain as little state as possible. - if conflictFileCount > 0 { + if conflictFileCount > 0 && prevConflictFileCount == 0 { if fileTreeViewModel.GetFilter() == filetree.DisplayAll { fileTreeViewModel.SetStatusFilter(filetree.DisplayConflicted) } - } else if fileTreeViewModel.GetFilter() == filetree.DisplayConflicted { + } else if conflictFileCount == 0 && fileTreeViewModel.GetFilter() == filetree.DisplayConflicted { fileTreeViewModel.SetStatusFilter(filetree.DisplayAll) }