From 2fde2f8329817889b96b540a296e9738197af032 Mon Sep 17 00:00:00 2001 From: Christian Hornung Date: Sat, 27 Sep 2008 13:39:05 +0000 Subject: [PATCH] Fixed the parse information not being updated when a window is closed with discarding the changes. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3558 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Workbench/Layouts/SdiWorkspaceWindow.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs index aa9ed6b2f7..a17f7b2a8e 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs @@ -335,6 +335,7 @@ namespace ICSharpCode.SharpDevelop.Gui public bool CloseWindow(bool force) { + bool fileDiscarded = false; if (!force && this.IsDirty) { DialogResult dr = MessageBox.Show(ResourceService.GetString("MainWindow.SaveChangesMessage"), ResourceService.GetString("MainWindow.SaveChangesMessageHeader") + " " + Title + " ?", @@ -350,6 +351,7 @@ namespace ICSharpCode.SharpDevelop.Gui vc.Files.Foreach(ICSharpCode.SharpDevelop.Commands.SaveFile.Save); if (vc.IsDirty) { if (MessageService.AskQuestion("${res:MainWindow.DiscardChangesMessage}")) { + fileDiscarded = true; break; } } else { @@ -360,14 +362,39 @@ namespace ICSharpCode.SharpDevelop.Gui } break; case DialogResult.No: + fileDiscarded = true; break; case DialogResult.Cancel: return false; } } + + // Create list of files to reparse after the window is closed. + // This is necessary because when changes were discarded, + // the ParserService still has the information with the changes + // that are now invalid. + string[] filesToReparse; + if (fileDiscarded) { + filesToReparse = this.ViewContents + .SelectMany(vc => vc.Files) + .Select(f => f.FileName) + .Distinct(StringComparer.OrdinalIgnoreCase) + .ToArray(); + } else { + filesToReparse = null; + } OnCloseEvent(null); Dispose(); + + if (filesToReparse != null) { + // This must happen after Dispose so that the ViewContents + // are closed and their content is no longer found by + // the ParserService. + LoggingService.Debug("SdiWorkspaceWindow closed with discarding changes, enqueueing files for parsing: " + String.Join(", ", filesToReparse)); + filesToReparse.Foreach(ParserService.EnqueueForParsing); + } + return true; }