Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authortherzok <marius.ungureanu@xamarin.com>2019-06-19 19:31:00 +0300
committermonojenkins <jo.shields+jenkins@xamarin.com>2019-07-03 20:06:03 +0300
commit633c9d8e427fcdadfb1a20a61153041d6bed2543 (patch)
tree19c6f9a5b8d007a5f37234f482fd5bb8d377126e /main
parente51a73fa2d80d26cfb5ebf2d45e9bb59e8168e90 (diff)
Fix up file not being saved correctly and updating registration for the roslyn document context
After debugging with @avodovnik, we found out that 2 registrations were done for the same document, one still pointing to the old path. Subscribing to the file document controller events on initialization fixes this, as the handler that was checking renames is subscribed there. Avoid manually saving a project, as there is a method that does that in TryApplyChanges. The Freeze/Thaw events are required because the roslyn file associations need to happen before the text buffer registration, otherwise the text buffer is associated with the miscellaneous files workspace as our workspace does not contain the new document file path yet.
Diffstat (limited to 'main')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/RoslynDocumentExtension.cs13
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs23
2 files changed, 13 insertions, 23 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/RoslynDocumentExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/RoslynDocumentExtension.cs
index 0d6add720d..d5153082dd 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/RoslynDocumentExtension.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/RoslynDocumentExtension.cs
@@ -136,6 +136,7 @@ namespace MonoDevelop.Ide.Gui
TryEditorInitialization ();
UpdateTextBufferRegistration ();
+ SubscribeControllerEvents ();
}
public void TryEditorInitialization ()
@@ -469,12 +470,6 @@ namespace MonoDevelop.Ide.Gui
Task EnsureAnalysisDocumentIsOpen ()
{
- if (Editor == null) {
- UnsubscribeAnalysisDocument ();
- UpdateTextBufferRegistration ();
- return Task.CompletedTask;
- }
-
if (analysisDocument != null) {
Microsoft.CodeAnalysis.Document doc;
try {
@@ -489,6 +484,12 @@ namespace MonoDevelop.Ide.Gui
return Task.CompletedTask;
}
+ if (Editor == null) {
+ UnsubscribeAnalysisDocument ();
+ UpdateTextBufferRegistration ();
+ return Task.CompletedTask;
+ }
+
lock (analysisDocumentLock) {
UnsubscribeRoslynWorkspace ();
RoslynWorkspace = typeSystemService.GetWorkspaceInternal (Project?.ParentSolution);
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs
index b141f582df..c7091b0934 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs
@@ -995,6 +995,7 @@ namespace MonoDevelop.Ide.TypeSystem
// as a result, we can assume that the things it calls are _also_ main thread only
Runtime.CheckMainThread ();
lock (projectModifyLock) {
+ FileService.FreezeEvents ();
freezeProjectModify = true;
try {
var ret = base.TryApplyChanges (newSolution, progressTracker);
@@ -1024,6 +1025,7 @@ namespace MonoDevelop.Ide.TypeSystem
tryApplyState_documentTextChangedTasks.Clear ();
tryApplyState_changedProjects.Clear ();
freezeProjectModify = false;
+ FileService.ThawEvents ();
}
}
}
@@ -1342,12 +1344,8 @@ namespace MonoDevelop.Ide.TypeSystem
return;
}
-
-
- DispatchService.PumpingWait (async () => {
- await Runtime.RunInMainThread (() => {
-
- FileService.FreezeEvents ();
+ DispatchService.PumpingWait (() => {
+ return Runtime.RunInMainThread (async () => {
FileService.RenameFile (document.FilePath, newName);
@@ -1358,19 +1356,10 @@ namespace MonoDevelop.Ide.TypeSystem
FileService.RenameFile (child.File.FilePath, child.NewName);
}
}
-
- // let's update all the things
- //var newPath = Path.Combine (Path.GetDirectoryName (document.FilePath), newName);
- //var newSolution = currentSolution.WithDocumentFilePath (id, newPath);
- //newSolution = newSolution.WithDocumentName (id, newName);
- //SetCurrentSolution (newSolution);
-
- FileService.ThawEvents ();
});
-
- await IdeApp.ProjectOperations.SaveAsync (mdProject);
-
});
+
+ tryApplyState_changedProjects.Add (mdProject);
}
static List<(MonoDevelop.Projects.ProjectFile File, string NewName)> GetDependentFilesToRename (