luminaxster/syntax-highlighter

Bug | Highlighting might not clear after disposal

Closed this issue · 1 comments

In rare cases where there was a change in monaco's content after disposal of highlightOnDidChangeModelContent
The highlight might stay there

Steps to reproduce:

  1. Set up monaco with JSX highlight library
  2. Register to highlightOnDidChangeModelContent
  3. Update monaco value (change from <></> to <div></div>
  4. Immediately call highlightOnDidChangeModelContent's dispose function

Expected Result:
No highlight

Result:
Incorrect highlight will be shown for the name of the JSX element

How to fix:
Add clearTimeout(tid); as the first line of:

const onDispose = () => {
this.decoratorMapper.reset();
if (
!_isHighlightBoundToModelContentChanges
) {
return;
}
_isHighlightBoundToModelContentChanges = false;
highlighterDisposer && highlighterDisposer.dispose();
highlighterDisposer = null;
}

Thank you so much, I will fix this and #22 next weekend.