Skip to content

Commit a92f7bc

Browse files
hltu1claude
andcommitted
fix: keep folder filter when checking out or creating a branch inside it
When the history is filtered with an included branch folder, checking out (or creating and checking out) a branch inside that folder replaced the folder filter with a filter for just that branch, because the automatic include also unsets every parent folder filter. Skip the automatic include when an ancestor folder filter with the same mode already covers the branch. Manual include clicks are unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SQ4PfsLku4ovivLiux3cYo
1 parent 61667f1 commit a92f7bc

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎src/Models/RepositoryUIStates.cs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,26 @@ public bool UpdateHistoryFilters(string pattern, FilterType type, FilterMode mod
357357
return true;
358358
}
359359

360+
public bool IsCoveredByFolderFilter(string path, FilterMode mode)
361+
{
362+
var idx = path.LastIndexOf('/');
363+
while (idx > 0)
364+
{
365+
var parent = path.Substring(0, idx);
366+
foreach (var filter in HistoryFilters)
367+
{
368+
if (filter.Type is FilterType.LocalBranchFolder or FilterType.RemoteBranchFolder &&
369+
filter.Mode == mode &&
370+
filter.Pattern.Equals(parent, StringComparison.Ordinal))
371+
return true;
372+
}
373+
374+
idx = parent.LastIndexOf('/');
375+
}
376+
377+
return false;
378+
}
379+
360380
public void RemoveHistoryFilter(string pattern, FilterType type)
361381
{
362382
foreach (var filter in HistoryFilters)

‎src/ViewModels/Repository.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,8 @@ public void RefreshAfterCreateBranch(Models.Branch created, bool checkout)
774774
if (folderEndIdx > 10)
775775
_uiStates.ExpandedBranchNodesInSideBar.Add(created.FullName.Substring(0, folderEndIdx));
776776

777-
if (_historyFilterMode == Models.FilterMode.Included)
777+
if (_historyFilterMode == Models.FilterMode.Included &&
778+
!_uiStates.IsCoveredByFolderFilter(created.FullName, Models.FilterMode.Included))
778779
SetBranchFilterMode(created, Models.FilterMode.Included, false, false);
779780

780781
CurrentBranch = created;
@@ -817,7 +818,8 @@ public void RefreshAfterCheckoutBranch(Models.Branch checkouted)
817818

818819
checkouted.IsCurrent = true;
819820
checkouted.WorktreePath = FullPath;
820-
if (_historyFilterMode == Models.FilterMode.Included)
821+
if (_historyFilterMode == Models.FilterMode.Included &&
822+
!_uiStates.IsCoveredByFolderFilter(checkouted.FullName, Models.FilterMode.Included))
821823
SetBranchFilterMode(checkouted, Models.FilterMode.Included, false, false);
822824

823825
List<Models.Branch> locals = [];

0 commit comments

Comments
 (0)