contentDom.blur() also removes highlighting

I am using contentDom.blur() to remove focus from a CM instance programmatically.

But it also removes highlighting (different tokens with different colors) and turns all the code monochromatic.

I am not able to reproduce this reliably. It happens every few tries.

Any thoughts on what could be going wrong? And what I can try to fix this?


That shouldn’t happen… and I can’t really think of a way in which it could happen. Selection will change color and matching bracket highlighting is removed when the editor blurs, but the syntax coloring should definitely stay.

I’ve only observed syntax highlighting disappearing when something causes the syntax highlighting extension to crash, causing cm6 to disable the plugin. Maybe you have some code that’s causing it to error out.

To help debug, you can add this to your list of extensions and check the developer console for errors the next time your issue happens.


(Passing the error to console.error is the default behavior when no exception sink is registered, so that extension won’t cause anything to change.)

Thank you for the replies! I solved it for now using a hack - I rebuild the editor instance after blurring it. This seems to work - it correctly keep the code syntax highlighted.

Huh ok, thanks for the tip! I think this wasn’t the case at one point in the past…