At Wikipedia, we had a customized fork of the bracket matching add-on for CodeMirror 5 that would highlight surrounding brackets, and not just when the cursor is next to a bracket. This is especially useful for MediaWiki wikitext because that language has lots of inline syntax, so the contextual highlighting really helps.
Anyway, I’d like to do the same in CodeMirror 6 but I’m not sure how to extend the native bracket matching. Basically, I’d like to provide my own implementation of matchBrackets() which would call the native one, and if null
is returned (cursor is not a bracket) then it would it search for surrounding brackets and call matchBrackets()
on those so that they are highlighted.
What would be the recommended way of doing this, if any, aside from having to rewrite all of the bracket matching code?
I also wanted to ask if there was any appetite to perhaps add an option for this in the bracket matching config. I know some IDEs have this behaviour by default, seemingly most do not, but nonetheless I assume its usefulness extends beyond Wikipedia.
Thanks for your time!