Fixed for rulechains

This commit is contained in:
mpetrov 2025-03-07 15:33:19 +02:00
parent 9dd89cc7b9
commit c55f9592f6

View File

@ -241,6 +241,7 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
this.updateJsWorkerGlobals(); this.updateJsWorkerGlobals();
this.initialCompleters = this.jsEditor.completers || []; this.initialCompleters = this.jsEditor.completers || [];
this.updateCompleters(); this.updateCompleters();
this.updateHighlightRules();
this.editorResize$ = new ResizeObserver(() => { this.editorResize$ = new ResizeObserver(() => {
this.onAceEditorResize(); this.onAceEditorResize();
}); });
@ -577,22 +578,24 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
private updateHighlightRules(): void { private updateHighlightRules(): void {
// @ts-ignore // @ts-ignore
if (!!this.highlightRules && !!this.jsEditor.session.$mode) { if (!!this.jsEditor.session.$mode) {
// @ts-ignore // @ts-ignore
const newMode = new this.jsEditor.session.$mode.constructor(); const newMode = new this.jsEditor.session.$mode.constructor();
newMode.$highlightRules = new newMode.HighlightRules(); newMode.$highlightRules = new newMode.HighlightRules();
for(const group in this.highlightRules) { if (!!this.highlightRules) {
if(!!newMode.$highlightRules.$rules[group]) { for(const group in this.highlightRules) {
newMode.$highlightRules.$rules[group].unshift(...this.highlightRules[group]); if(!!newMode.$highlightRules.$rules[group]) {
} else { newMode.$highlightRules.$rules[group].unshift(...this.highlightRules[group]);
newMode.$highlightRules.$rules[group] = this.highlightRules[group]; } else {
newMode.$highlightRules.$rules[group] = this.highlightRules[group];
}
} }
} }
if (this.scriptLanguage === ScriptLanguage.TBEL) { if (this.scriptLanguage === ScriptLanguage.TBEL) {
newMode.$highlightRules.$rules.start = [...tbelUtilsFuncHighlightRules, ...newMode.$highlightRules.$rules.start]; newMode.$highlightRules.$rules.start = [...tbelUtilsFuncHighlightRules, ...newMode.$highlightRules.$rules.start];
} }
const identifierRule = newMode.$highlightRules.$rules.no_regex.find(rule => rule.token?.includes('identifier')); const identifierRule = newMode.$highlightRules.$rules.no_regex.find(rule => rule.token?.includes('identifier'));
if (identifierRule) { if (identifierRule && identifierRule.next === 'no_regex') {
identifierRule.next = 'start'; identifierRule.next = 'start';
} }
// @ts-ignore // @ts-ignore