I would like to add an option to always highlight unmatched brackets/braces/parentheses, rather than only highlighting the one next to the cursor. I’ve prototyped two solutions:
-
Apply a bookmark to each bracket in the document using setBookmark() - initially for the whole doc, then incrementally by listening to the “changes” event and only updating bookmarks for the modified lines. This is faster and requires less code than approach 2, but I wanted to confirm if it’s safe to set so many bookmarks (potentially thousands) in one file. Seems fine in my testing.
-
Do not store any bracket related state, and only highlight bookmarks in the visual range. Scan before and after the visual range to see if there is any match. The disadvantage is that in the worst case it can require a scan of the entire document. Doing it async in small batches keeps the app responsive, but it can take a while for the highlight to show up.
I’ll send a pull request with my proposed changes, but wanted to check first to see if you have any concerns with approach 1, which seems better to me.