From e99f26df9088fc4b455915b866fcd8243f319311 Mon Sep 17 00:00:00 2001 From: Jai <814683@qq.com> Date: Thu, 15 Jul 2021 12:48:44 +0800 Subject: [PATCH] fix: the expanded status of the repository branch list is not saved correctly --- src/Views/Widgets/Dashboard.xaml | 9 +++++---- src/Views/Widgets/Dashboard.xaml.cs | 14 +++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Views/Widgets/Dashboard.xaml b/src/Views/Widgets/Dashboard.xaml index ce05cf7a..af525321 100644 --- a/src/Views/Widgets/Dashboard.xaml +++ b/src/Views/Widgets/Dashboard.xaml @@ -214,14 +214,14 @@ - + - + @@ -250,6 +250,7 @@ SelectionChanged="OnTreeSelectionChanged"> @@ -290,14 +291,14 @@ - + - + diff --git a/src/Views/Widgets/Dashboard.xaml.cs b/src/Views/Widgets/Dashboard.xaml.cs index 57318f2d..1dc0bd70 100644 --- a/src/Views/Widgets/Dashboard.xaml.cs +++ b/src/Views/Widgets/Dashboard.xaml.cs @@ -113,9 +113,9 @@ namespace SourceGit.Views.Widgets { private void BackupBranchExpandState(Dictionary states, List nodes, string prefix) { foreach (var node in nodes) { if (node.Type != BranchNodeType.Branch) { - var id = prefix + node.Name + "/"; + var id = string.Concat(prefix, "/", node.Name); states[id] = node.IsExpanded; - BackupBranchExpandState(states, node.Children, id + "/"); + BackupBranchExpandState(states, node.Children, id); } } } @@ -138,7 +138,7 @@ namespace SourceGit.Views.Widgets { BranchNode lastFolder = null; string path = prefix; for (int i = 0; i < subs.Length - 1; i++) { - path = path + subs[i] + "/"; + path = string.Concat(path, "/", subs[i]); if (folders.ContainsKey(path)) { lastFolder = folders[path]; } else if (lastFolder == null) { @@ -189,8 +189,8 @@ namespace SourceGit.Views.Widgets { repo.Remotes = new Commands.Remotes(repo.Path).Result(); var states = new Dictionary(); - BackupBranchExpandState(states, localBranches, "locals/"); - BackupBranchExpandState(states, remoteBranches, "remotes/"); + BackupBranchExpandState(states, localBranches, "locals"); + BackupBranchExpandState(states, remoteBranches, "remotes"); var folders = new Dictionary(); localBranches = new List(); @@ -210,10 +210,10 @@ namespace SourceGit.Views.Widgets { foreach (var b in repo.Branches) { if (b.IsLocal) { - MakeBranchNode(b, localBranches, folders, states, "locals/"); + MakeBranchNode(b, localBranches, folders, states, "locals"); } else { var r = remoteBranches.Find(x => x.Name == b.Remote); - if (r != null) MakeBranchNode(b, r.Children, folders, states, $"remotes/{b.Remote}/"); + if (r != null) MakeBranchNode(b, r.Children, folders, states, $"remotes/{b.Remote}"); } }