diff options
2 files changed, 8 insertions, 77 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlDocumentController.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlDocumentController.cs index 0b9082bfd3..e843005e61 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlDocumentController.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlDocumentController.cs @@ -49,7 +49,6 @@ namespace MonoDevelop.VersionControl DocumentView blameView; DocumentView logView; DocumentView mergeView; - private DocumentView mainView; public override async Task<bool> SupportsController (DocumentController controller) { @@ -71,84 +70,22 @@ namespace MonoDevelop.VersionControl repo = VersionControlService.GetRepository (project); if (repo == null) return false; - - return true; + return repo.TryGetVersionInfo (fileController.FilePath, out var info) && info.IsVersioned; } protected internal override async Task<DocumentView> OnInitializeView () { - mainView = await base.OnInitializeView (); + var mainView = await base.OnInitializeView (); var controller = (FileDocumentController)Controller; var item = new VersionControlItem (repo, project, controller.FilePath, false, null); vcInfo = new VersionControlDocumentInfo (this, Controller, item, item.Repository); vcInfo.Document = Controller.Document; - await UpdateSubviewsAsync (); - VersionControlService.FileStatusChanged += VersionControlService_FileStatusChanged; - return mainView; - } - - public override void Dispose () - { - VersionControlService.FileStatusChanged -= VersionControlService_FileStatusChanged; - base.Dispose (); - } - - void VersionControlService_FileStatusChanged (object sender, FileUpdateEventArgs args) - { - - foreach (var file in args) { - if (!vcInfo.Document.FilePath.IsNullOrEmpty && vcInfo.Document.FilePath.Equals (file.FilePath)) { - Runtime.RunInMainThread (async () => { - await UpdateSubviewsAsync (); - }); - } - } - } - bool showSubviews; - async Task UpdateSubviewsAsync () - { - var hasVersionInfo = repo.TryGetVersionInfo (this.vcInfo.Document.FilePath, out var info); - if (hasVersionInfo) - vcInfo.Item.VersionInfo = info; - - if (!hasVersionInfo || !info.IsVersioned) { - if (!showSubviews) - return; - showSubviews = false; - if (diffView != null) { - mainView.AttachedViews.Remove (diffView); - diffView.Dispose (); - diffView = null; - } - - if (blameView != null) { - mainView.AttachedViews.Remove (blameView); - blameView.Dispose (); - blameView = null; - } - - if (logView != null) { - mainView.AttachedViews.Remove (logView); - logView.Dispose (); - logView = null; - } - - if (mergeView != null) { - mainView.AttachedViews.Remove (mergeView); - mergeView.Dispose (); - mergeView = null; - } - - } else { - if (showSubviews) - return; - showSubviews = true; - diffView = await TryAttachView (mainView, vcInfo, DiffCommand.DiffViewHandlers, GettextCatalog.GetString ("Changes"), GettextCatalog.GetString ("Shows the differences in the code between the current code and the version in the repository")); - blameView = await TryAttachView (mainView, vcInfo, BlameCommand.BlameViewHandlers, GettextCatalog.GetString ("Authors"), GettextCatalog.GetString ("Shows the authors of the current file")); - logView = await TryAttachView (mainView, vcInfo, LogCommand.LogViewHandlers, GettextCatalog.GetString ("Log"), GettextCatalog.GetString ("Shows the source control log for the current file")); - mergeView = await TryAttachView (mainView, vcInfo, MergeCommand.MergeViewHandlers, GettextCatalog.GetString ("Merge"), GettextCatalog.GetString ("Shows the merge view for the current file")); - } + diffView = await TryAttachView (mainView, vcInfo, DiffCommand.DiffViewHandlers, GettextCatalog.GetString ("Changes"), GettextCatalog.GetString ("Shows the differences in the code between the current code and the version in the repository")); + blameView = await TryAttachView (mainView, vcInfo, BlameCommand.BlameViewHandlers, GettextCatalog.GetString ("Authors"), GettextCatalog.GetString ("Shows the authors of the current file")); + logView = await TryAttachView (mainView, vcInfo, LogCommand.LogViewHandlers, GettextCatalog.GetString ("Log"), GettextCatalog.GetString ("Shows the source control log for the current file")); + mergeView = await TryAttachView (mainView, vcInfo, MergeCommand.MergeViewHandlers, GettextCatalog.GetString ("Merge"), GettextCatalog.GetString ("Shows the merge view for the current file")); + return mainView; } async Task<DocumentView> TryAttachView (DocumentView mainView, VersionControlDocumentInfo info, string type, string title, string description) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentView.cs index 4653c8cc37..c942826160 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentView.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/DocumentView.cs @@ -363,7 +363,6 @@ namespace MonoDevelop.Ide.Gui.Documents mainShellView.LostFocus += ShellContentView_LostFocus; if (IsRoot && AttachedViews.Count > 0) { CreateAttachmentsContainer (); - InitializeAttachmentsContainer (); } else shellView = mainShellView; @@ -383,16 +382,12 @@ namespace MonoDevelop.Ide.Gui.Documents int pos = 1; foreach (var attachedView in AttachedViews) attachmentsContainer.InsertView (pos++, attachedView.CreateShellView (window)); - shellView = attachmentsContainer; - } - - private void InitializeAttachmentsContainer () - { if (activeAttachedView == this) attachmentsContainer.ActiveView = mainShellView; else attachmentsContainer.ActiveView = activeAttachedView?.ShellView; attachmentsContainer.ActiveViewChanged += AttachmentsContainer_ActiveViewChanged; + shellView = attachmentsContainer; } private void ShellContentView_GotFocus (object sender, EventArgs e) @@ -453,7 +448,6 @@ namespace MonoDevelop.Ide.Gui.Documents CreateAttachmentsContainer (); UpdateTitle (); ReplaceViewInParent (); - InitializeAttachmentsContainer (); } } else { if (attachmentsContainer != null) { |