feature: remember last active tab index if restore tabs is enabled

This commit is contained in:
leo 2024-03-06 19:46:19 +08:00
parent 0e824f12b4
commit 3bf962d745
2 changed files with 11 additions and 0 deletions

View file

@ -30,6 +30,11 @@ namespace SourceGit.ViewModels {
OpenRepositoryInTab(node, null); OpenRepositoryInTab(node, null);
} }
var lastActiveIdx = Preference.Instance.LastActiveTabIdx;
if (lastActiveIdx >= 0 && lastActiveIdx < Pages.Count) {
ActivePage = Pages[lastActiveIdx];
}
} }
} }
@ -42,6 +47,7 @@ namespace SourceGit.ViewModels {
} }
} }
Preference.Instance.LastActiveTabIdx = Pages.IndexOf(ActivePage);
Preference.Save(); Preference.Save();
} }

View file

@ -178,6 +178,11 @@ namespace SourceGit.ViewModels {
set; set;
} = new List<string>(); } = new List<string>();
public int LastActiveTabIdx {
get;
set;
} = 0;
public static void AddNode(RepositoryNode node, RepositoryNode to = null) { public static void AddNode(RepositoryNode node, RepositoryNode to = null) {
var collection = to == null ? _instance._repositoryNodes : to.SubNodes; var collection = to == null ? _instance._repositoryNodes : to.SubNodes;
var list = new List<RepositoryNode>(); var list = new List<RepositoryNode>();