I have a CodeMirror 6 editor that uses the official lang-markdown
mode. This mode styles the markdown code using decorations unless the text is selected, in which case the styling is removed, similar to HyperMD or Obsidian. This behavior can cause a feedback loop: selecting text causes it to lose styling, which shifts the content and changes the selection, causing the text to be re-rendered, and the cycle repeats.
I want to avoid these visual glitches by delaying rendering until the mouse button is released, as Obsidian does. I’m unsure how to achieve this. I thought about using a transactionFilter
, but there’s no transaction emitted when the mouse is released, leading me to think that buffering transactions might be necessary. Are there other options or guidance someone could provide?
Edit: Custom Statefields, which I have implemented, style the markdown with decorations, not lang-markdown
. The Statefields re-compute the decorations on every update by iterating over the syntaxTree
.