Skip to content

Commit 4308c73

Browse files
committed
Save changes through the returned doc reference.
1 parent 5d01d37 commit 4308c73

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

External/Plugins/CodeRefactor/Commands/Move.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ private void UpdateReferencesNextTarget()
358358
oldType = oldType.Trim('.');
359359
MessageBar.Locked = true;
360360
string newFilePath = currentTarget.NewFilePath;
361-
ScintillaControl sci = AssociatedDocumentHelper.LoadDocument(currentTarget.TmpFilePath ?? newFilePath).SciControl;
361+
var doc = AssociatedDocumentHelper.LoadDocument(currentTarget.TmpFilePath ?? newFilePath);
362+
ScintillaControl sci = doc.SciControl;
362363
List<SearchMatch> matches = search.Matches(sci.Text);
363364
string packageReplacement = "package";
364365
if (currentTarget.NewPackage != "")
@@ -383,7 +384,7 @@ private void UpdateReferencesNextTarget()
383384
}
384385
//Do we want to open modified files?
385386
//if (sci.IsModify) AssociatedDocumentHelper.MarkDocumentToKeep(file);
386-
PluginBase.MainForm.CurrentDocument.Save();
387+
doc.Save();
387388
MessageBar.Locked = false;
388389
UserInterfaceManager.ProgressDialog.Show();
389390
UserInterfaceManager.ProgressDialog.SetTitle(TextHelper.GetString("Info.FindingReferences"));
@@ -507,6 +508,7 @@ private void FindFinished(FRResults results)
507508
entry.Key == currentTarget.NewFilePath) continue;
508509
string file = entry.Key;
509510
UserInterfaceManager.ProgressDialog.UpdateStatusMessage(TextHelper.GetString("Info.Updating") + " \"" + file + "\"");
511+
ITabbedDocument doc;
510512
ScintillaControl sci;
511513
var actualMatches = new List<SearchMatch>();
512514
foreach (SearchMatch match in entry.Value)
@@ -521,7 +523,8 @@ private void FindFinished(FRResults results)
521523
}
522524
if (actualMatches.Count == 0) continue;
523525
int currLine = -1;
524-
sci = AssociatedDocumentHelper.LoadDocument(file).SciControl;
526+
doc = AssociatedDocumentHelper.LoadDocument(file);
527+
sci = doc.SciControl;
525528
string directory = Path.GetDirectoryName(file);
526529
// Let's check if we need to add the import. Check the considerations at the start of the file
527530
// directory != currentTarget.OwnerPath -> renamed owner directory, so both files in the same place
@@ -579,7 +582,7 @@ private void FindFinished(FRResults results)
579582
Results[file].AddRange(actualMatches);
580583
//Do we want to open modified files?
581584
//if (sci.IsModify) AssociatedDocumentHelper.MarkDocumentToKeep(file);
582-
PluginBase.MainForm.CurrentDocument.Save();
585+
doc.Save();
583586
}
584587

585588
currentTargetIndex++;

External/Plugins/CodeRefactor/Commands/Rename.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,13 @@ private void OnFindAllReferencesCompleted(Object sender, RefactorCompleteEventAr
242242
{
243243
UserInterfaceManager.ProgressDialog.UpdateStatusMessage(TextHelper.GetString("Info.Updating") + " \"" + entry.Key + "\"");
244244
// re-open the document and replace all the text
245-
var sci = AssociatedDocumentHelper.LoadDocument(entry.Key).SciControl;
245+
var doc = AssociatedDocumentHelper.LoadDocument(entry.Key);
246+
var sci = doc.SciControl;
246247
// replace matches in the current file with the new name
247248
RefactoringHelper.ReplaceMatches(entry.Value, sci, this.newName);
248249
//Uncomment if we want to keep modified files
249250
//if (sci.IsModify) AssociatedDocumentHelper.MarkDocumentToKeep(entry.Key);
250-
PluginBase.MainForm.CurrentDocument.Save();
251+
doc.Save();
251252
}
252253
if (newFileName != null) RenameFile(eventArgs.Results);
253254
this.Results = eventArgs.Results;

0 commit comments

Comments
 (0)