diff --git a/src/ViewModels/BranchTreeNode.cs b/src/ViewModels/BranchTreeNode.cs index a8232047..698dc7ad 100644 --- a/src/ViewModels/BranchTreeNode.cs +++ b/src/ViewModels/BranchTreeNode.cs @@ -58,6 +58,7 @@ namespace SourceGit.ViewModels { public List Locals => _locals; public List Remotes => _remotes; + public List InvalidExpandedNodes => _invalidExpandedNodes; public void SetExpandedNodes(List expanded) { @@ -98,6 +99,12 @@ namespace SourceGit.ViewModels } } + foreach (var path in _expanded) + { + if (!folders.ContainsKey(path)) + _invalidExpandedNodes.Add(path); + } + folders.Clear(); SortNodes(_locals); SortNodes(_remotes); @@ -188,6 +195,7 @@ namespace SourceGit.ViewModels private readonly List _locals = new List(); private readonly List _remotes = new List(); + private readonly List _invalidExpandedNodes = new List(); private readonly HashSet _expanded = new HashSet(); } } diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 993597a5..82197bdf 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -2088,6 +2088,9 @@ namespace SourceGit.ViewModels { builder.SetExpandedNodes(_settings.ExpandedBranchNodesInSideBar); builder.Run(branches, remotes, false); + + foreach (var invalid in builder.InvalidExpandedNodes) + _settings.ExpandedBranchNodesInSideBar.Remove(invalid); } else {