Closed pmg23 closed 2 years ago
matchbrackets won't help much here -- it assumes opening and closing brackets are distinguishable, and the brackets are separate tokens. But you should be able to write a custom extension that does this, probably by recognizing quoted tokens in the tree and highlighting their first and last characters (possibly checking if the closing character is there if you're tokenizing in an error-correcting way, for example by force-ending string tokens at line ends).
Hi
I'm using CodeMirror 6 with
bracketMatching()
andLanguageSupport
using a custom Lezer parser. The custom grammar includes string literals delimited by double-quote characters, with support for escapes (\"
and\\
). I'd like it to be that when the cursor is at a quote delimiter (start or end) the matching delimiter is highlighted - in the same way that this works for the various types of brackets.For example (screenshot from JetBrains Rider editing C#):
So far I have been unable to achieve this, either using
@detectDelim
(the ideal case) or by manual insertion ofopenedBy
/closedBy
node props in the grammar. (With the latter approach I can see the NodeProps metadata in the generated parser, butbracketMatching()
doesn't work quite right.)Please will you confirm if such behaviour is supported/possible in the present version? If so I wonder could you please update the example grammar to demonstrate it or the Lezer docs to explain how? If not, please could you consider this a feature request?
Best regards Matt