Announce Matches Upon Scroll

Just to preface this, I am loving the new update for CodeMirror.

We’re trying to move our editor from Monaco to CodeMirror 6, and one of the features that caught my eye was the Search feature; in particular, it works really great, but as we scroll down a larger document, it doesn’t highlight additional matches. For example, take a look at this sandbox I spun up. Here are the directions to replicate the issue I had:

  1. Search for the word function.
  2. Scroll down to roughly line 247 (without any keystrokes), where we have another instance of the word function without any highlighting.
Digging through the code to find any quick remedies, I noted that announceMatch is the function that does the highlighting, but it's only called on search/next/previous. It would be cool to see if CodeMirror could also implement this on scroll (similar to how Lezer works on scroll for large documents).

I would implement this myself, but I’m not too sure about the best design practices. I can create a PR, if you’d like, and we can go from there.

Right, thanks for spotting that. The patch linked below should fix that.

(Edit: initially linked the wrong patch)

1 Like