diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs index f97f4b9745..24ddf57dbf 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs @@ -47,6 +47,12 @@ namespace PythonBinding.Tests.Utils } } + public ICollection PrimaryViewContents { + get { + throw new NotImplementedException(); + } + } + public List PadContentCollection { get { throw new NotImplementedException(); diff --git a/src/Main/Base/Project/Src/Gui/IWorkbench.cs b/src/Main/Base/Project/Src/Gui/IWorkbench.cs index 74591e08b0..00e5ac8a61 100644 --- a/src/Main/Base/Project/Src/Gui/IWorkbench.cs +++ b/src/Main/Base/Project/Src/Gui/IWorkbench.cs @@ -33,12 +33,19 @@ namespace ICSharpCode.SharpDevelop.Gui } /// - /// A collection in which all opened view contents are saved. + /// A collection in which all opened view contents (including all secondary view contents) are saved. /// ICollection ViewContentCollection { get; } + /// + /// A collection in which all opened primary view contents are saved. + /// + ICollection PrimaryViewContents { + get; + } + /// /// A collection in which all active workspace windows are saved. /// diff --git a/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs b/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs index a95969d7a8..9ef5c6164a 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs @@ -31,7 +31,7 @@ namespace ICSharpCode.SharpDevelop.Gui readonly static string viewContentPath = "/SharpDevelop/Workbench/Pads"; List padViewContentCollection = new List(); - List viewContentCollection = new List(); + List primaryViewContentCollection = new List(); bool isActiveWindow; // Gets whether SharpDevelop is the active application in Windows @@ -113,17 +113,26 @@ namespace ICSharpCode.SharpDevelop.Gui public IList WorkbenchWindowCollection { get { - return viewContentCollection.Select(vc => vc.WorkbenchWindow) + return primaryViewContentCollection.Select(vc => vc.WorkbenchWindow) .Distinct().ToArray().AsReadOnly(); } } - public ICollection ViewContentCollection { + public ICollection PrimaryViewContents { get { // return Linq.ToArray(Linq.Concat(Linq.Select>( // workbenchWindowCollection, delegate (IWorkbenchWindow w) { return w.ViewContents; } // ))); - return viewContentCollection.AsReadOnly(); + return primaryViewContentCollection.AsReadOnly(); + } + } + + public ICollection ViewContentCollection { + get { + ICollection primaryContents = PrimaryViewContents; + List contents = new List(primaryContents); + contents.AddRange(primaryContents.SelectMany(vc => vc.SecondaryViewContents)); + return contents.AsReadOnly(); } } @@ -292,8 +301,8 @@ namespace ICSharpCode.SharpDevelop.Gui if (PropertyService.Get("SharpDevelop.LoadDocumentProperties", true) && content is IMementoCapable) { StoreMemento(content); } - if (viewContentCollection.Contains(content)) { - viewContentCollection.Remove(content); + if (primaryViewContentCollection.Contains(content)) { + primaryViewContentCollection.Remove(content); } OnViewClosed(new ViewContentEventArgs(content)); content.Dispose(); @@ -316,7 +325,7 @@ namespace ICSharpCode.SharpDevelop.Gui public void ShowView(IViewContent content) { System.Diagnostics.Debug.Assert(layout != null); - viewContentCollection.Add(content); + primaryViewContentCollection.Add(content); if (PropertyService.Get("SharpDevelop.LoadDocumentProperties", true) && content is IMementoCapable) { try { Properties memento = GetStoredMemento(content); diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs index cc76fae3d1..221ff6e9ff 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs @@ -180,7 +180,7 @@ namespace ICSharpCode.SharpDevelop.Gui } void ShowViewContents() { - foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) { + foreach (IViewContent content in WorkbenchSingleton.Workbench.PrimaryViewContents) { ShowView(content); } } diff --git a/src/Main/Base/Project/Src/Services/File/FileService.cs b/src/Main/Base/Project/Src/Services/File/FileService.cs index cc19e30d85..70e01783b8 100644 --- a/src/Main/Base/Project/Src/Services/File/FileService.cs +++ b/src/Main/Base/Project/Src/Services/File/FileService.cs @@ -278,7 +278,7 @@ namespace ICSharpCode.SharpDevelop List fileNames = new List(); foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) { string contentName = content.PrimaryFileName; - if (contentName != null) + if (contentName != null && !fileNames.Contains(contentName)) fileNames.Add(contentName); } return fileNames; diff --git a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs index 6bff317dfe..911ad59e36 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Sda/Src/CallHelper.cs @@ -229,8 +229,8 @@ namespace ICSharpCode.SharpDevelop.Sda bool CloseWorkbenchInternal(bool force) { if (force) { - foreach (IViewContent vc in WorkbenchSingleton.Workbench.ViewContentCollection.ToArray()) { - vc.WorkbenchWindow.CloseWindow(true); + foreach (IWorkbenchWindow window in WorkbenchSingleton.Workbench.WorkbenchWindowCollection.ToArray()) { + window.CloseWindow(true); } } WorkbenchSingleton.MainForm.Close();