-
Notifications
You must be signed in to change notification settings - Fork 6
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 syntax highlighting for param tag #31
base: main
Are you sure you want to change the base?
Conversation
This commit fixes an issue where the param tag would incorrectly match the first "-" found and comment anything after it. This broke snake case variables and other similar cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple comments, but overall good 👍
{ | ||
"include": "#liquid_doc_fallback_tag" | ||
} | ||
] | ||
}, | ||
"liquid_doc_param_tag": { | ||
"match": "(@param)\\s+(?:({[^}]*}?)\\s+)?([a-zA-Z_]\\w*)?", | ||
"match": "(@param)\\s+(?:({[^}]*}?)\\s+)?([a-zA-Z_][\\w-]*)?(?:\\s+(.*))?", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"match": "(@param)\\s+(?:({[^}]*}?)\\s+)?([a-zA-Z_][\\w-]*)?(?:\\s+(.*))?", | |
"match": "(@param)\\s+(?:({[^}]*}?)\\s+)?(\\[?[a-zA-Z_][\\w-]*\\]?)?(?:\\s+(.*))?", |
Let's also capture optional params
"match": "(@description)\\b", | ||
"captures": { | ||
"1": { | ||
"name": "storage.type.class.liquid" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closes: https://github.com/Shopify/developer-tools-team/issues/557
Note There is some code from the description PR that I have in here to ensure everything is working. I will rebase once we merge that.
What is this PR doing?
There was a syntax highlighting error when you would have a hyphen in a variable name before the hyphen used to show a description in a param tag.
For example"
@param {String} title - The title of the product
would properly highlight the code.@param {String} my-title - The title of the product
would stop highlighting properly aftermy-
This is because we were matching on the first hyphen found. I've reworked the matching and now we look for the first space after the variable name. This is a lot more robust.
The changes work even if you don't add the variable type such as
{String}
Before:

After:
