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

Commit 4f99f1a

Browse files
committed
Fix debouncer not updating highlighting
1 parent a7b33d4 commit 4f99f1a

File tree

1 file changed

+47
-43
lines changed

1 file changed

+47
-43
lines changed

UI/Components/EditorElement.xaml.cs

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public EditorElement(string filePath)
135135

136136
colorizeSelection = new ColorizeSelection();
137137
editor.TextArea.TextView.LineTransformers.Add(colorizeSelection);
138-
editor.SyntaxHighlighting = new AeonEditorHighlighting();
138+
ParseIncludes(null, null);
139139

140140
LoadAutoCompletes();
141141

@@ -648,65 +648,69 @@ private void Caret_PositionChanged(object sender, EventArgs e)
648648
parseTimer.Close();
649649
}
650650

651-
parseTimer = new Timer(500)
651+
parseTimer = new Timer(200)
652652
{
653653
AutoReset = false,
654654
Enabled = true,
655655
};
656656
parseTimer.Elapsed += ParseIncludes;
657657
}
658658

659-
private static void ParseIncludes(object sender, EventArgs e)
659+
private void ParseIncludes(object sender, EventArgs e)
660660
{
661-
var ee = Program.MainWindow.GetAllEditorElements();
662-
var ce = Program.MainWindow.GetCurrentEditorElement();
661+
Dispatcher.Invoke(() =>
662+
{
663+
var ee = Program.MainWindow.GetAllEditorElements();
664+
var ce = Program.MainWindow.GetCurrentEditorElement();
665+
666+
var caret = -1;
663667

664-
var caret = -1;
668+
if (ee == null) return;
665669

666-
if (ee == null) return;
670+
var definitions = new SMDefinition[ee.Length];
671+
List<SMFunction> currentFunctions = null;
672+
for (var i = 0; i < ee.Length; ++i)
673+
{
674+
var el = ee[i];
675+
var fInfo = new FileInfo(el.FullFilePath);
676+
var text = el.editor.Document.Text;
677+
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "inc")
678+
definitions[i] =
679+
new Condenser(text
680+
, fInfo.Name).Condense();
667681

668-
var definitions = new SMDefinition[ee.Length];
669-
List<SMFunction> currentFunctions = null;
670-
for (var i = 0; i < ee.Length; ++i)
671-
{
672-
var el = ee[i];
673-
var fInfo = new FileInfo(el.FullFilePath);
674-
var text = el.editor.Document.Text;
675-
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "inc")
676-
definitions[i] =
677-
new Condenser(text
678-
, fInfo.Name).Condense();
682+
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "sp")
683+
if (el.IsLoaded)
684+
{
685+
caret = el.editor.CaretOffset;
686+
definitions[i] =
687+
new Condenser(text, fInfo.Name)
688+
.Condense();
689+
currentFunctions = definitions[i].Functions;
690+
}
691+
}
679692

680-
if (fInfo.Extension.Trim('.').ToLowerInvariant() == "sp")
681-
if (el.IsLoaded)
682-
{
683-
caret = el.editor.CaretOffset;
684-
definitions[i] =
685-
new Condenser(text, fInfo.Name)
686-
.Condense();
687-
currentFunctions = definitions[i].Functions;
688-
}
689-
}
693+
var smDef = Program.Configs[Program.SelectedConfig].GetSMDef()
694+
.ProduceTemporaryExpandedDefinition(definitions, caret, currentFunctions);
695+
var smFunctions = smDef.Functions.ToArray();
696+
var acNodes = smDef.ProduceACNodes();
697+
var isNodes = smDef.ProduceISNodes();
690698

691-
var smDef = Program.Configs[Program.SelectedConfig].GetSMDef()
692-
.ProduceTemporaryExpandedDefinition(definitions, caret, currentFunctions);
693-
var smFunctions = smDef.Functions.ToArray();
694-
var acNodes = smDef.ProduceACNodes();
695-
var isNodes = smDef.ProduceISNodes();
699+
ce.editor.SyntaxHighlighting = new AeonEditorHighlighting(smDef);
696700

697-
ce.editor.SyntaxHighlighting = new AeonEditorHighlighting(smDef);
698-
foreach (var el in ee)
699-
{
700-
if (el == ce)
701+
foreach (var el in ee)
701702
{
702-
Debug.Assert(ce != null, nameof(ce) + " != null");
703-
if (ce.ISAC_Open) continue;
704-
}
703+
if (el == ce)
704+
{
705+
Debug.Assert(ce != null, nameof(ce) + " != null");
706+
if (ce.ISAC_Open) continue;
707+
}
705708

706709

707-
el.InterruptLoadAutoCompletes(smDef.FunctionStrings, smFunctions, acNodes,
708-
isNodes, smDef.Methodmaps.ToArray(), smDef.Variables.ToArray());
709-
}
710+
el.InterruptLoadAutoCompletes(smDef.FunctionStrings, smFunctions, acNodes,
711+
isNodes, smDef.Methodmaps.ToArray(), smDef.Variables.ToArray());
712+
}
713+
});
710714
}
711715

712716
private void TextArea_TextEntered(object sender, TextCompositionEventArgs e)

0 commit comments

Comments
 (0)