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

Fix is not syntax highlighting #260

Merged
merged 2 commits into from
Jan 29, 2024
Merged

Fix is not syntax highlighting #260

merged 2 commits into from
Jan 29, 2024

Conversation

j-malt
Copy link
Contributor

@j-malt j-malt commented Jan 26, 2024

Context: Issue #257

The token is not was being incorrectly captured in our syntax. This PR updates the syntax regex to correctly capture this token. Here is a test snippet from the original issue, and the updated syntax highlighting:

  <div>
    {%- if classes and (classes is string) -%}
        {% set classes = classes|split(" ") %}
    {%- elif (classes is not string) and not (classes is string) or not foo -%}
        {% set classes = classes|split(",") %}
    {%- elif (classes is not string) and (classes is not iterable) or not foo -%}
        {% set classes = [] %}
    {%- endif -%}
  </div>

Before

Screen capture 2024-01-26 at 12 30@2x

After

Screen capture 2024-01-26 at 12 30@2x

Verified

This commit was signed with the committer’s verified signature.
codebytere Shelley Vohr

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@@ -37,7 +37,7 @@ To enable Emmet on your `html-hubl` files, you can map `html-hubl` to `html` in

### IntelliSense Suggestions

If you are would like to get IntelliSense suggestions when in snippet placeholders, you will need to add the following to your user settings:
If you would like to get IntelliSense suggestions when in snippet placeholders, you will need to add the following to your user settings:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fixes a typo

Comment on lines +109 to +112
{
"match": "\\b(and|else|if|in|import|(is )?not|or|recursive|with(out)?\\s+context)\\b",
"name": "keyword.control.hubl"
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this up in the file so that it takes precedence over the x is y syntax highlighting, which was breaking the x is not y syntax highlight, since it was being captured as x (is) not y instead of x (is not) y. I've also added the optional group (is )? so it captures is not here.

@@ -115,7 +119,7 @@
"name": "variable.other.hubl.test"
}
},
"match": "\\s*\\b(is)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\b"
"match": "\\s*\\b(is)(?!\\s+not)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\b"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a non-capturing group for is so that this doesn't match x is not y, only x is y. We need to keep this group around because the alternative (adding is to the group above) would match independent is tokens incorrectly, so x not is y would get highlighted as an operator which seems undesirable (really we should error on that but outside the scope of this change).

@j-malt j-malt requested review from jsines and TanyaScales January 26, 2024 17:37
@j-malt j-malt marked this pull request as ready for review January 26, 2024 17:37
Copy link
Member

@TanyaScales TanyaScales left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for getting this quick fix in

@j-malt j-malt mentioned this pull request Jan 29, 2024
@j-malt j-malt merged commit 2629b84 into master Jan 29, 2024
1 check passed
@j-malt j-malt deleted the jm/issue-257 branch January 29, 2024 19:41
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.

Typo on the listing Inconsistent/misleading highlighting for not logical operator
2 participants