hello, i got the hihlighting function
const backgroundEffect = (view: ViewUpdate, problemTree?: TriggerTargetProblem): void => {
if (!view.docChanged || !view.viewportChanged) {
return;
}
const effects: StateEffect<BadFunctionDecoration>[] = [];
const doc = view.state.doc.toString();
const syntax = syntaxTree(view.state);
syntax.iterate({
enter(node) {
if (node.name !== "FunctionName" || !problemTree) {
return;
}
const from = node.from;
const to = node.to;
const elementString = doc.substring(from, to);
const badFunction = defineFunction(elementString, problemTree);
if (!badFunction) {
return;
}
effects.push(
addBackgroundDecoration.of({
from,
to,
problemTree,
})
);
return false;
},
});
if (effects.length > 0) {
view.view.dispatch({ effects });
}
};
and this is how its implemented
EditorView.updateListener.of((view) => backgroundEffect(view, problemTree)),
but the problem is that highlighting is not applied when code is firstly loaded
but it works fine when doc is changed
can’t realise how to firstly update the state with givven code