Browse Source

Fixed SD2-699: New file name does not increment

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1441 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
782aac1504
  1. 8
      src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs
  2. 16
      src/Main/Base/Project/Src/Services/File/FileService.cs

8
src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs

@ -310,9 +310,15 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -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)) {
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;
}

16
src/Main/Base/Project/Src/Services/File/FileService.cs

@ -6,12 +6,11 @@ @@ -6,12 +6,11 @@
// </file>
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 @@ -128,6 +127,17 @@ namespace ICSharpCode.Core
}
}
public static IList<string> GetOpenFiles()
{
List<string> fileNames = new List<string>();
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) {

Loading…
Cancel
Save