mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
optimize(*): speed up for openning same repository that already opened before
This commit is contained in:
parent
65d89897f1
commit
073c189f18
4 changed files with 22 additions and 12 deletions
|
@ -54,8 +54,8 @@ namespace SourceGit {
|
||||||
if (main == null) return null;
|
if (main == null) return null;
|
||||||
if (repo == null) return (main.Tabs[0].Page as UI.Manager).popupManager;
|
if (repo == null) return (main.Tabs[0].Page as UI.Manager).popupManager;
|
||||||
|
|
||||||
for (int i = 1; i < main.openedTabs.Items.Count; i++) {
|
for (int i = 1; i < main.Tabs.Count; i++) {
|
||||||
var opened = main.openedTabs.Items[i] as UI.Launcher.Tab;
|
var opened = main.Tabs[i];
|
||||||
if (opened.Repo.Path == repo.Path) {
|
if (opened.Repo.Path == repo.Path) {
|
||||||
return (opened.Page as UI.Dashboard).popupManager;
|
return (opened.Page as UI.Dashboard).popupManager;
|
||||||
}
|
}
|
||||||
|
|
|
@ -958,7 +958,8 @@ namespace SourceGit.UI {
|
||||||
sub.Path = Path.Combine(repo.Path, path);
|
sub.Path = Path.Combine(repo.Path, path);
|
||||||
sub.Name = Path.GetFileName(path);
|
sub.Name = Path.GetFileName(path);
|
||||||
sub.Parent = repo;
|
sub.Parent = repo;
|
||||||
sub.Open();
|
|
||||||
|
if (!(App.Current.MainWindow as Launcher).GotoRepo(sub)) sub.Open();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -48,14 +48,6 @@ namespace SourceGit.UI {
|
||||||
|
|
||||||
Git.Repository.OnOpen = repo => {
|
Git.Repository.OnOpen = repo => {
|
||||||
Dispatcher.Invoke(() => {
|
Dispatcher.Invoke(() => {
|
||||||
for (int i = 1; i < openedTabs.Items.Count; i++) {
|
|
||||||
var opened = openedTabs.Items[i] as Tab;
|
|
||||||
if (opened.Repo.Path == repo.Path) {
|
|
||||||
openedTabs.SelectedItem = opened;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var tab = new Tab() {
|
var tab = new Tab() {
|
||||||
Title = repo.Parent == null ? repo.Name : $"{repo.Parent.Name} : {repo.Name}",
|
Title = repo.Parent == null ? repo.Name : $"{repo.Parent.Name} : {repo.Name}",
|
||||||
Repo = repo,
|
Repo = repo,
|
||||||
|
@ -76,6 +68,23 @@ namespace SourceGit.UI {
|
||||||
openedTabs.SelectedItem = Tabs[0];
|
openedTabs.SelectedItem = Tabs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Goto opened repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="repo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool GotoRepo(Git.Repository repo) {
|
||||||
|
for (int i = 1; i < Tabs.Count; i++) {
|
||||||
|
var opened = Tabs[i];
|
||||||
|
if (opened.Repo.Path == repo.Path) {
|
||||||
|
openedTabs.SelectedItem = opened;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#region LAYOUT_CONTENT
|
#region LAYOUT_CONTENT
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Close repository tab.
|
/// Close repository tab.
|
||||||
|
|
|
@ -402,7 +402,7 @@ namespace SourceGit.UI {
|
||||||
}
|
}
|
||||||
|
|
||||||
var repo = App.Preference.AddRepository(path, "");
|
var repo = App.Preference.AddRepository(path, "");
|
||||||
repo.Open();
|
if (!(App.Current.MainWindow as Launcher).GotoRepo(repo)) repo.Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue