From 795f6f88f759bb579f323ecdb3db33695bd252f4 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Thu, 18 Nov 2010 20:11:41 +0000 Subject: [PATCH] Fix SD-1748 - ArgumentException when saving file using the name of another file already open in the editor --- .../Base/Project/Src/Services/File/FileService.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Main/Base/Project/Src/Services/File/FileService.cs b/src/Main/Base/Project/Src/Services/File/FileService.cs index 20c2601a95..07b41e60d1 100644 --- a/src/Main/Base/Project/Src/Services/File/FileService.cs +++ b/src/Main/Base/Project/Src/Services/File/FileService.cs @@ -146,9 +146,14 @@ namespace ICSharpCode.SharpDevelop if (openedFileDict[oldName] != file) throw new ArgumentException("file must be registered as oldName"); - if (openedFileDict.ContainsKey(newName)) - throw new ArgumentException("there already is a file with the newName"); - + if (openedFileDict.ContainsKey(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[newName] = file; }