BracketHighlighter icon indicating copy to clipboard operation
BracketHighlighter copied to clipboard

Please support '<' ">' angle bracket in multiple line template in c++

Open MambaWong opened this issue 7 years ago • 5 comments

Please support '<' ">' angle bracket in multiple line template in c++ like the 'red' angle brackets in below image. qq 20171224155749

Because more and more people like to use template In modern C++ 11. Thank you!

MambaWong avatar Dec 24 '17 08:12 MambaWong

  1. Please follow the template next time.

  2. Pull requests are welcome.

As I am a C++ user, I may get to this in the future, but it is low priority for me, so a pull request will most likely get it in much quicker.

facelessuser avatar Dec 24 '17 16:12 facelessuser

This is something that will be really helpful for me!

I have had horrible bugs in template meta-programming just because sometimes is hard to distinguish if angles were right or not, and the compiler does not help very much.

Another example of use, is to analyse errors of the generated code after some meta-programing. You literally get hundreds of angles, and one of them can give you clues where the error is coming from.

SoilRos avatar Jun 19 '18 17:06 SoilRos

Unfortunately, I rarely touch templates in the kind of C/C++ coding I do (mostly embedded systems). That's not to say templates aren't used in our code, I just rarely have to touch that area. Because of that, this has been pretty low on my priority list.

Also, If the current syntax language doesn't scope these special, it may be difficult to pull this off as there are many ways angle brackets are used: shifting, comparing, header include, templates, etc.

Anyways, it is on my list, I just can't promise when I'll get around to looking into this.

facelessuser avatar Jun 19 '18 19:06 facelessuser

Yes I understand that is very demanding, even compilers had troubles in the beginning to understand these codes. Even if you could program something that can recognise these scopes, I guess it will make BracketHighlighter very slow. So, I don't think that should be the approach here.

Instead I would go in another direction which might be very easy to implement: activate template highlighter (i.e. a simple angle highlighter) with a hotkey when needed. The reason is that outside templates, angle brackets are very messy and difficult to understand and would require a lot of work to distinguish, however, inside templates there cannot be pointer operators, shifts operator, and static comparisons must be done within a parenthesis scope. It means that a simple angle highlighter is more than enough.

Right now my approach is something near to that: I have a simple angle highlighter that I enable by hand only when i really need to be sure that templates are correct.

Do you think that is too hard to add such a hotkey?

SoilRos avatar Jun 20 '18 12:06 SoilRos

I haven't looked yet, but if I have to code up a special template highlighter, that would be more difficult. I may be able to use existing Scopes, I just don't know yet. When I get a chance, I'll let you know.

facelessuser avatar Jun 20 '18 13:06 facelessuser