Text not highlighted after EditorView.scrollIntoView

I’m working on this webapp, where the writers may write thousands of chapters and should be able to jump between them using the side menu.

I use the following code to perform the jump:

    selection: {anchor: editor.state.doc.line(
      book.index.chapters.get(key).contentEnd + 1
    scrollIntoView: true,
    effects: [
      subviewUpdateEffect.of("subviewUpdate"), // ignore this one, should be irrelevant
          book.index.chapters.get(key).contentStart + 1
        { y: 'start', yMargin: 20, }

If I jump too far away (i.e., from chapter 1 to 700), the text on screen is not highlighted. It gets highlighted as soon as I scroll a bit or edit the chapter.

Am I missing something? Is there a way to force a refresh?

Parsing work is throttled so as to not slow down the UI and not waste too much cpu/battery/power. That means that if you are way down a big document, it may take a while to catch up, and if the editor isn’t active, it may stop doing work altogether on the assumption that the user isn’t working with it.

Not the case here. I’ve waited 5mins and still no updates. If scroll a bit the update happens in seconds.

Also, keep in mind I’m calling editor.focus() after the transition.

Edit: after an hour, still no update, even when clicking on the editor. Definitely a bug.

Looks like new work time is only being allocated when the viewport (for scrolling) or the document changes. I guess we could extend that to also respond to selection updates (and thus to clicks). But that still won’t guarantee you’ll get highlighting when leaving the editor idle somewhere down a big document. The fact remains that catching up with parsing on the bottom of a big document is going to potentially be a lot of work, and that it’s a bad idea for a UI component to just keep spinning and using CPU when idle.

Can’t you just put a flag on EditorView.scrollIntoView in order to trigger a viewport update after the scrolling as if it was a user scrolling?

Or provide another way to forcefully trigger the highlighting?

Any news on this?

Again, the problem is that a programmatic scrollIntoView does not trigger the parser, not even after hours. This is a severe bug for my use case.

If you wish, I may try to implement it by myself and propose a pull request. If you have any suggestion on how to implement, let me know.

The scroll will be triggering a new time budget chunk for the highlighter. But it runs out of that budget before finishing highlighting up to the visible code, and since there’s no further activity, it will go idle. This is how it is supposed to behave.