diff options
author | Sandy Armstrong <sandy@xamarin.com> | 2019-12-04 01:53:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-04 01:53:02 +0300 |
commit | ce928d9dda263d87a05f0b11307761d32d7b3432 (patch) | |
tree | 6433df24d69e29f8e2c88d121399d736672daa11 | |
parent | 58560fb7c4a651a9c5b5e632cfb422497c4ce7d8 (diff) | |
parent | 622a9e096f3d8aaadf9b132ed5bf7deb9b0747de (diff) |
Merge pull request #9377 from mono/backport-pr-9376-to-release-8.4
[release-8.4] Fixes squiggles in Razor/Blazor files after project reload
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/DynamicFileManager.cs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/DynamicFileManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/DynamicFileManager.cs index 80dac3ba84..f3de469729 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/DynamicFileManager.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/DynamicFileManager.cs @@ -88,11 +88,18 @@ namespace MonoDevelop.Ide.TypeSystem private void OnDynamicDocumentUpdated (DocumentInfo document) { if (projectContexts.TryGetValue (document.Id.ProjectId, out var projectContext)) { - if (projectContext.Workspace.IsDocumentOpen (document.Id)) { + var workspace = projectContext.Workspace; + if (workspace.IsDocumentOpen (document.Id)) { return; } - projectContext.Workspace.OnDocumentReloaded (document); + if (!workspace.CurrentSolution.ContainsDocument (document.Id)) { + // By the time we get called back from Razor the project might + // have been unloaded + return; + } + + workspace.OnDocumentReloaded (document); } } @@ -114,7 +121,6 @@ namespace MonoDevelop.Ide.TypeSystem var newFiles = currentDynamicSourceFiles.ToImmutableHashSet (); dynamicSourceFiles = newFiles; - var addedFiles = newFiles.Except (oldFiles); var removedFiles = oldFiles.Except (newFiles); foreach (var document in removedFiles) { @@ -128,14 +134,16 @@ namespace MonoDevelop.Ide.TypeSystem List<DocumentInfo> documents = new List<DocumentInfo> (); - foreach (var document in addedFiles) { + foreach (var document in dynamicSourceFiles) { foreach (var dynamicFileProvider in dynamicFileManager.GetDynamicFileProviders (document)) { var dynamicFileInfo = dynamicFileProvider.GetDynamicDocumentInfo ( projectInfo.Id, projectInfo.FilePath, document); - if (dynamicFileInfo != null) { + bool alreadyAdded = projectInfo.Documents.Any (d => string.Equals (d.FilePath, document, StringComparison.OrdinalIgnoreCase)); + + if (dynamicFileInfo != null && !alreadyAdded) { documents.Add (dynamicFileInfo); } } |