diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs index 545df2085f..5556be304c 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs @@ -310,9 +310,15 @@ namespace ICSharpCode.SharpDevelop.Gui StringParser.Properties["Number"] = curNumber.ToString(); string fileName = StringParser.Parse(SelectedTemplate.DefaultName); if (allowUntitledFiles) { - if (!FileService.IsOpen(fileName)) { - break; + bool found = false; + foreach (string openFile in FileService.GetOpenFiles()) { + if (Path.GetFileName(openFile) == fileName) { + found = true; + break; + } } + if (found == false) + break; } else if (!File.Exists(Path.Combine(basePath, fileName))) { break; } diff --git a/src/Main/Base/Project/Src/Services/File/FileService.cs b/src/Main/Base/Project/Src/Services/File/FileService.cs index 02981eb2f7..2cd1c9e5cb 100644 --- a/src/Main/Base/Project/Src/Services/File/FileService.cs +++ b/src/Main/Base/Project/Src/Services/File/FileService.cs @@ -6,12 +6,11 @@ // using System; -using System.Diagnostics; +using System.Collections.Generic; using System.IO; -using System.Xml; -using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Project; namespace ICSharpCode.Core { @@ -128,6 +127,17 @@ namespace ICSharpCode.Core } } + public static IList GetOpenFiles() + { + List fileNames = new List(); + foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) { + string contentName = content.IsUntitled ? content.UntitledName : content.FileName; + if (contentName != null) + fileNames.Add(contentName); + } + return fileNames; + } + public static IWorkbenchWindow GetOpenFile(string fileName) { if (fileName != null && fileName.Length > 0) {