Skip to content

Commit 5d01d37

Browse files
committed
Changed most uses of MainForm.OpenEditableDocument that just afterwards use MainForm.CurrentDocument to get the corresponding ScintillaControl. Instead use the returned ITabbedDocument.
1 parent 44871aa commit 5d01d37

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

External/Plugins/CodeRefactor/Commands/FindAllReferences.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ private void FindFinished(FRResults results)
126126
if (fileEntries.Value.Count > 0 && System.IO.File.Exists(fileEntries.Key))
127127
{
128128
SearchMatch entry = fileEntries.Value[0];
129-
PluginBase.MainForm.OpenEditableDocument(fileEntries.Key, false);
130-
RefactoringHelper.SelectMatch(PluginBase.MainForm.CurrentDocument.SciControl, entry);
129+
var doc = (ITabbedDocument)PluginBase.MainForm.OpenEditableDocument(fileEntries.Key, false);
130+
RefactoringHelper.SelectMatch(doc.SciControl, entry);
131131
break;
132132
}
133133
}
@@ -158,7 +158,7 @@ private IDictionary<String, List<SearchMatch>> ResolveActualMatches(FRResults re
158158
// we have to open/reopen the entry's file
159159
// there are issues with evaluating the declaration targets with non-open, non-current files
160160
// we have to do it each time as the process of checking the declaration source can change the currently open file!
161-
ScintillaControl sci = this.AssociatedDocumentHelper.LoadDocument(currentFileName);
161+
ScintillaControl sci = this.AssociatedDocumentHelper.LoadDocument(currentFileName).SciControl;
162162
// if the search result does point to the member source, store it
163163
if (RefactoringHelper.DoesMatchPointToTarget(sci, match, target, this.AssociatedDocumentHelper))
164164
{

External/Plugins/CodeRefactor/Commands/Move.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ private void UpdateReferencesNextTarget()
358358
oldType = oldType.Trim('.');
359359
MessageBar.Locked = true;
360360
string newFilePath = currentTarget.NewFilePath;
361-
ScintillaControl sci = AssociatedDocumentHelper.LoadDocument(currentTarget.TmpFilePath ?? newFilePath);
361+
ScintillaControl sci = AssociatedDocumentHelper.LoadDocument(currentTarget.TmpFilePath ?? newFilePath).SciControl;
362362
List<SearchMatch> matches = search.Matches(sci.Text);
363363
string packageReplacement = "package";
364364
if (currentTarget.NewPackage != "")
@@ -514,14 +514,14 @@ private void FindFinished(FRResults results)
514514
// we have to open/reopen the entry's file
515515
// there are issues with evaluating the declaration targets with non-open, non-current files
516516
// we have to do it each time as the process of checking the declaration source can change the currently open file!
517-
sci = AssociatedDocumentHelper.LoadDocument(file);
517+
sci = AssociatedDocumentHelper.LoadDocument(file).SciControl;
518518
// if the search result does point to the member source, store it
519519
if (RefactoringHelper.DoesMatchPointToTarget(sci, match, currentTargetResult, this.AssociatedDocumentHelper))
520520
actualMatches.Add(match);
521521
}
522522
if (actualMatches.Count == 0) continue;
523523
int currLine = -1;
524-
sci = AssociatedDocumentHelper.LoadDocument(file);
524+
sci = AssociatedDocumentHelper.LoadDocument(file).SciControl;
525525
string directory = Path.GetDirectoryName(file);
526526
// Let's check if we need to add the import. Check the considerations at the start of the file
527527
// directory != currentTarget.OwnerPath -> renamed owner directory, so both files in the same place

External/Plugins/CodeRefactor/Commands/Rename.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ 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);
245+
var sci = AssociatedDocumentHelper.LoadDocument(entry.Key).SciControl;
246246
// replace matches in the current file with the new name
247247
RefactoringHelper.ReplaceMatches(entry.Value, sci, this.newName);
248248
//Uncomment if we want to keep modified files

External/Plugins/CodeRefactor/Provider/DocumentHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ public void MarkDocumentToKeep(String fileName)
130130
/// If the document was not already previously opened, this will flag
131131
/// it as a temporary file.
132132
/// </summary>
133-
public ScintillaControl LoadDocument(String fileName)
133+
public ITabbedDocument LoadDocument(String fileName)
134134
{
135135
ITabbedDocument newDocument = (ITabbedDocument)PluginBase.MainForm.OpenEditableDocument(fileName);
136136
this.RegisterLoadedDocument(newDocument);
137-
return ASContext.CurSciControl;
137+
return newDocument;
138138
}
139139

140140
/// <summary>

External/Plugins/CodeRefactor/Provider/RefactoringHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public static ASResult GetRefactorTargetFromFile(string path, DocumentHelper ass
107107
{
108108
String fileName = Path.GetFileNameWithoutExtension(path);
109109
Int32 line = 0;
110-
ScintillaControl sci = associatedDocumentHelper.LoadDocument(path);
110+
var doc = associatedDocumentHelper.LoadDocument(path);
111+
ScintillaControl sci = doc != null ? doc.SciControl : null;
111112
if (sci == null) return null; // Should not happen...
112113
List<ClassModel> classes = ASContext.Context.CurrentModel.Classes;
113114
if (classes.Count > 0)

External/Plugins/FlashDebugger/Helpers/ScintillaHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,9 @@ static public void ActivateDocument(string filefullpath)
332332

333333
static public ScintillaControl ActivateDocument(string filefullpath, int line, Boolean bSelectLine)
334334
{
335-
PluginBase.MainForm.OpenEditableDocument(filefullpath, false);
336-
if (PluginBase.MainForm.CurrentDocument.FileName != filefullpath) return null;
337-
ScintillaControl sci = PluginBase.MainForm.CurrentDocument.SciControl;
335+
var doc = PluginBase.MainForm.OpenEditableDocument(filefullpath, false) as ITabbedDocument;
336+
if (doc == null || doc.FileName != filefullpath) return null;
337+
ScintillaControl sci = doc.SciControl;
338338
if (line >= 0)
339339
{
340340
sci.EnsureVisible(line);

FlashDevelop/Dialogs/FRInFilesDialog.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,10 @@ private void ResultsViewDoubleClick(Object sender, System.EventArgs e)
631631
if (File.Exists(data.Key))
632632
{
633633
Globals.MainForm.Activate();
634-
Globals.MainForm.OpenEditableDocument(data.Key, false);
635-
if (Globals.CurrentDocument.IsEditable)
634+
var doc = Globals.MainForm.OpenEditableDocument(data.Key, false) as ITabbedDocument;
635+
if (doc != null && doc.IsEditable)
636636
{
637-
ScintillaControl sci = Globals.CurrentDocument.SciControl;
637+
ScintillaControl sci = doc.SciControl;
638638
if (this.resultsView.Columns.Count == 4)
639639
{
640640
Int32 column = sci.MBSafeTextLength(data.Value.LineText.Substring(0, data.Value.Column));

0 commit comments

Comments
 (0)