Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve single line import expression syntax highlighting #508 #29

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

alehechka
Copy link
Contributor

Overview

Partially resolves a-h/templ#508.

I found that the previous begin regex for import-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

before

After

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.

@a-h a-h merged commit b3ebe7f into templ-go:main Feb 13, 2024
@a-h
Copy link
Collaborator

a-h commented Feb 13, 2024

Thanks for that, much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vscode: Inconsistent syntax highlighting in vscode.
2 participants