Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 853b5de

Browse files
committed
Fix MainWindow error
1 parent 36546ce commit 853b5de

File tree

1 file changed

+39
-40
lines changed

1 file changed

+39
-40
lines changed

UI/Components/EditorElement.xaml.cs

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -635,57 +635,56 @@ private void Caret_PositionChanged(object sender, EventArgs e)
635635
bracketHighlightRenderer.SetHighlight(result);
636636

637637

638-
if (Program.OptionsObject.Program_DynamicISAC)
639-
{
640-
var ee = Program.MainWindow.GetAllEditorElements();
641-
var ce = Program.MainWindow.GetCurrentEditorElement();
638+
if (!Program.OptionsObject.Program_DynamicISAC || Program.MainWindow == null) return;
639+
640+
var ee = Program.MainWindow.GetAllEditorElements();
641+
var ce = Program.MainWindow.GetCurrentEditorElement();
642642

643-
var caret = -1;
643+
var caret = -1;
644644

645-
if (ee != null)
645+
if (ee != null)
646+
{
647+
var definitions = new SMDefinition[ee.Length];
648+
List<SMFunction> currentFunctions = null;
649+
for (var i = 0; i < ee.Length; ++i)
646650
{
647-
var definitions = new SMDefinition[ee.Length];
648-
List<SMFunction> currentFunctions = null;
649-
for (var i = 0; i < ee.Length; ++i)
650-
{
651-
var el = ee[i];
652-
var fInfo = new FileInfo(el.FullFilePath);
653-
var text = el.editor.Document.Text;
654-
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "inc")
655-
definitions[i] =
656-
new Condenser(text
657-
, fInfo.Name).Condense();
651+
var el = ee[i];
652+
var fInfo = new FileInfo(el.FullFilePath);
653+
var text = el.editor.Document.Text;
654+
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "inc")
655+
definitions[i] =
656+
new Condenser(text
657+
, fInfo.Name).Condense();
658658

659-
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "sp")
659+
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "sp")
660+
{
661+
if (el.IsLoaded)
660662
{
661-
if (el.IsLoaded)
662-
{
663-
caret = el.editor.CaretOffset;
664-
definitions[i] =
665-
new Condenser(text, fInfo.Name)
666-
.Condense();
667-
currentFunctions = definitions[i].Functions;
668-
}
663+
caret = el.editor.CaretOffset;
664+
definitions[i] =
665+
new Condenser(text, fInfo.Name)
666+
.Condense();
667+
currentFunctions = definitions[i].Functions;
669668
}
670669
}
670+
}
671671

672-
var smDef = Program.Configs[Program.SelectedConfig].GetSMDef()
673-
.ProduceTemporaryExpandedDefinition(definitions, caret, currentFunctions);
674-
var smFunctions = smDef.Functions.ToArray();
675-
var acNodes = smDef.ProduceACNodes();
676-
var isNodes = smDef.ProduceISNodes();
672+
var smDef = Program.Configs[Program.SelectedConfig].GetSMDef()
673+
.ProduceTemporaryExpandedDefinition(definitions, caret, currentFunctions);
674+
var smFunctions = smDef.Functions.ToArray();
675+
var acNodes = smDef.ProduceACNodes();
676+
var isNodes = smDef.ProduceISNodes();
677677

678-
foreach (var el in ee)
678+
foreach (var el in ee)
679+
{
680+
if (el == ce)
679681
{
680-
if (el == ce)
681-
{
682-
Debug.Assert(ce != null, nameof(ce) + " != null");
683-
if (ce.ISAC_Open) continue;
684-
}
685-
686-
el.InterruptLoadAutoCompletes(smDef.FunctionStrings, smFunctions, acNodes,
687-
isNodes, smDef.Methodmaps.ToArray(), smDef.Variables.ToArray());
682+
Debug.Assert(ce != null, nameof(ce) + " != null");
683+
if (ce.ISAC_Open) continue;
688684
}
685+
686+
el.InterruptLoadAutoCompletes(smDef.FunctionStrings, smFunctions, acNodes,
687+
isNodes, smDef.Methodmaps.ToArray(), smDef.Variables.ToArray());
689688
}
690689
}
691690
}

0 commit comments

Comments
 (0)