SublimeText / PackageDev

Tools to ease the creation of snippets, syntax definitions, etc. for Sublime Text.
MIT License
436 stars 83 forks source link

Highlight regex capture groups when in the captures: section. #102

Closed Thom1729 closed 7 years ago

Thom1729 commented 7 years ago

Implementation for #92.

Features:

Known shortcomings:

Other remarks:

FichteFoll commented 7 years ago

Please address all comments by @keith-hall and the warnings emitted by flake8. Other than that, this looks pretty good.

keith-hall commented 7 years ago

Oh yeah, sorry @Thom1729, I forgot to say I like the way you implemented it :) About the two shortcomings, I personally don't think anyone should ever have the captures above the corresponding regex, as its a bit odd, so I don't see that as a problem. Also the main use I have is with a single selection that doesn't span multiple lines so I don't see it as a problem that it only highlights the capture relating to the first selected line. Thanks for taking the time to work on this supremely useful feature :)

Thom1729 commented 7 years ago

Everything should be good except for the settings. That, I think, should be factored out from HighlightTestViewEventListener, but I'm not sure where in the project would be appropriate. Somewhere in /sublime_lib?

FichteFoll commented 7 years ago

See https://github.com/SublimeText/PackageDev/blob/cf3c44d19f019382c764a264bb6b3962429373db/syntax-test_dev.py#L298-L300.

We could probably factor out the following verification code for the style flags, though. Since sublime_lib is effectively ours, it seems like an okay-ish place.

Thom1729 commented 7 years ago

I committed a copy-paste of the existing implementation. It may be worth a new issue to abstract out some of Sublime's flag enums, including this one.

FichteFoll commented 7 years ago

Thanks for this; squashed into b9711f50e8bcda448f50ee0052c78d08b867843d.