diff --git a/SourceGit/App.xaml.cs b/SourceGit/App.xaml.cs index fed0ffda..ce22b182 100644 --- a/SourceGit/App.xaml.cs +++ b/SourceGit/App.xaml.cs @@ -54,8 +54,8 @@ namespace SourceGit { if (main == null) return null; if (repo == null) return (main.Tabs[0].Page as UI.Manager).popupManager; - for (int i = 1; i < main.openedTabs.Items.Count; i++) { - var opened = main.openedTabs.Items[i] as UI.Launcher.Tab; + for (int i = 1; i < main.Tabs.Count; i++) { + var opened = main.Tabs[i]; if (opened.Repo.Path == repo.Path) { return (opened.Page as UI.Dashboard).popupManager; } diff --git a/SourceGit/UI/Dashboard.xaml.cs b/SourceGit/UI/Dashboard.xaml.cs index 8cc33b22..d4994fab 100644 --- a/SourceGit/UI/Dashboard.xaml.cs +++ b/SourceGit/UI/Dashboard.xaml.cs @@ -958,7 +958,8 @@ namespace SourceGit.UI { sub.Path = Path.Combine(repo.Path, path); sub.Name = Path.GetFileName(path); sub.Parent = repo; - sub.Open(); + + if (!(App.Current.MainWindow as Launcher).GotoRepo(sub)) sub.Open(); } #endregion diff --git a/SourceGit/UI/Launcher.xaml.cs b/SourceGit/UI/Launcher.xaml.cs index 1d9146cb..b45c16b5 100644 --- a/SourceGit/UI/Launcher.xaml.cs +++ b/SourceGit/UI/Launcher.xaml.cs @@ -48,14 +48,6 @@ namespace SourceGit.UI { Git.Repository.OnOpen = repo => { 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() { Title = repo.Parent == null ? repo.Name : $"{repo.Parent.Name} : {repo.Name}", Repo = repo, @@ -76,6 +68,23 @@ namespace SourceGit.UI { openedTabs.SelectedItem = Tabs[0]; } + /// + /// Goto opened repository. + /// + /// + /// + 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 /// /// Close repository tab. diff --git a/SourceGit/UI/Manager.xaml.cs b/SourceGit/UI/Manager.xaml.cs index c8bcbf4b..2bf5d5f7 100644 --- a/SourceGit/UI/Manager.xaml.cs +++ b/SourceGit/UI/Manager.xaml.cs @@ -402,7 +402,7 @@ namespace SourceGit.UI { } var repo = App.Preference.AddRepository(path, ""); - repo.Open(); + if (!(App.Current.MainWindow as Launcher).GotoRepo(repo)) repo.Open(); } ///