Resolve single line import expression syntax highlighting #508 #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Partially resolves a-h/templ#508.
I found that the previous
begin
regex forimport-expression
would close when it hit the first open curly brace. I updated this regex to instead pattern match@
, a function name, open/close parenthesis, then the opening curly brace. This resolved the issue for inline cases.Additionally, I added an
empty-import-expression
that only matches against all but the opening curly brace for inline components that are not provided children.Before
After
However, this does not entirely resolve a-h/templ#508 which specifically asked about multi-line parameters. After reading up on TextMate (which is what VSCode uses under the hood) and finding this issue, it seems that multi-line pattern matching is not natively supported. It does seem possible to nest pattern matching to properly resolve the multi-line params, but I figured this fix was enough for one PR.
I'll likely spend some more time exploring TextMate and see if I can resolve the multi-line param syntax highlighting and can push another PR later.