notepad4 icon indicating copy to clipboard operation
notepad4 copied to clipboard

Brackets don't match across strings using different quote marks

Open meteorquake opened this issue 9 months ago • 5 comments

A lot of languages use ' or " or ` for string quotations and programmers jump around with which they are using depending on the string concerned.

Currently bracket pairs of various kinds ( ) [ ] { } highlight when the cursor is on one of them when they are in the same type of quoted string but not different quotation types, so -

The brackets highlight here when touched - 'a(bc'+'de)f'

but don't with these -

'a(bc'+"de)f"
'a(bc'+`de)f`

My view is matching should also be done when quote marks differ (like the second 2). It's very helpful that brackets are matched within strings as well as within code.

Cheers! David

meteorquake avatar Mar 10 '25 13:03 meteorquake

This is hard to fix, brace matching only match braces with same style, so operator braces don't match braces inside strings. most lexers color double and single quoted strings as different styles (to simplify tracking of closing quote).

zufuliu avatar Mar 16 '25 12:03 zufuliu

Many thanks! Perhaps an issue that can be raised with the scintilla group?

meteorquake avatar Mar 16 '25 18:03 meteorquake

Maybe not worth it, but you can ask Neil (@nyamatongwe).

zufuliu avatar Mar 17 '25 12:03 zufuliu

Doubt it's worth implementing myself. There could be an option for not checking styles.

nyamatongwe avatar Mar 17 '25 21:03 nyamatongwe

Perhaps there's a simple way to achieve it, perhaps - without knowing the innards - through quote styles having a hidden attribute 'Bracketing Group', because it would be very helpful to have it, the current arrangement being contrary to common sense from a user point of view. But I'll leave that up to you to think about, I can only encourage its exploration since brackets in strings invariably need matching up, an example is the common situation of code outputting a web document complete with JS.

meteorquake avatar Mar 18 '25 05:03 meteorquake