Browse Source

Fix SD-1748 - ArgumentException when saving file using the name of another file already open in the editor

pull/14/head
Matt Ward 15 years ago
parent
commit
795f6f88f7
  1. 11
      src/Main/Base/Project/Src/Services/File/FileService.cs

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

@ -146,9 +146,14 @@ namespace ICSharpCode.SharpDevelop
if (openedFileDict[oldName] != file) if (openedFileDict[oldName] != file)
throw new ArgumentException("file must be registered as oldName"); throw new ArgumentException("file must be registered as oldName");
if (openedFileDict.ContainsKey(newName)) if (openedFileDict.ContainsKey(newName)) {
throw new ArgumentException("there already is a file with the newName"); OpenedFile oldFile = openedFileDict[newName];
if (oldFile.CurrentView != null) {
oldFile.CurrentView.WorkbenchWindow.CloseWindow(true);
} else {
throw new ArgumentException("there already is a file with the newName");
}
}
openedFileDict.Remove(oldName); openedFileDict.Remove(oldName);
openedFileDict[newName] = file; openedFileDict[newName] = file;
} }

Loading…
Cancel
Save