overlay parse stops early

For some reason overlay parse stops early if the doc passes a certain character count threshold.

Example working correctly:

Example not working (by adding just one more character to a comment):

html’s code folding also doesn’t work in the case where the parse has stopped early:

Making any edit to the document causes a re-parse which does work correctly, but scrolling does not.

I’ve reproduced this odd behavior in a failing lang-twig test

I can’t reproduce this in a plain editor. With code like below (using the doc value from your test), all the comments get highlighted.

let editor = new CodeMirror(document.body, {
  lineNumbers: true,
  value: doc.repeat(5)
  token(stream, state) {
    if (stream.match("//")) { stream.skipToEnd(); return "comment" }

Oh sorry I should have specified better, this is happening with CodeMirror 6 and parseMixed with overlay nesting:

wrap: parseMixed(node => {
    if (!node.type.isTop){
      return null;

    return {
      parser: htmlLanguage.parser,
      overlay: node => node.type.name == "Text"

I added a plain (non-React) example in case it’s helpful!

Well, I finally figured out what was going on here. Was a dumb bug somewhere deep in the mixed parsing logic. This patch should help.