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 conditional local var highlight #2719

Merged
merged 5 commits into from
Oct 17, 2024

Conversation

v010maaa
Copy link
Contributor

@v010maaa v010maaa commented Oct 12, 2024

Motivation

Closes #2690

This PR address the issue where syntax highlighting was not applied to syntax that assigns variables within conditions, such as if (a=1).

Implementation

  • Address the syntax highlighting for local variable assignments within the conditions of case, if, elsif, unless, until, and while statements.
  • Arithmetic operations such as +=, -=, *=, /=, and %= are also supported in the same manner.
Statement Supported Example Notes
case case (x = foo) -
if if (x = foo) -
elsif elsif (x = foo) -
unless unless (x = foo) -
until until (x = foo) -
while while (x = foo) -
for for i in (x = 1..10) Not applicable; assignment in range not typical
begin begin (x = foo) Not applicable; doesn't have a condition
rescue rescue (x = foo) Assignment in rescue condition not supported
else else (x = foo) -
ensure ensure (x = foo) Not applicable; doesn't have a condition

Automated Tests

Added three cases to check if(i=1), if(i+=1) and if(i&&=1)

Manual Tests

AS-IS TOBE
Screenshot 2024-10-13 at 4 07 53 Screenshot 2024-10-13 at 4 07 07

@v010maaa v010maaa changed the title [WIP] Fix conditional local var highlight Fix conditional local var highlight Oct 12, 2024
@v010maaa v010maaa marked this pull request as ready for review October 12, 2024 20:23
@v010maaa v010maaa requested a review from a team as a code owner October 12, 2024 20:23
@v010maaa
Copy link
Contributor Author

I have signed the CLA!

Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

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

This is great. Can we also add the other forms of assignment? This is adding regular assignment and assignment operator. We are missing local variable and assignment and local variable or assignment. E.g.:

if (a ||= something)
end

if (a &&= something)
end

vscode/grammars/ruby.cson.json Outdated Show resolved Hide resolved
@vinistock vinistock added bugfix This PR will fix an existing bug vscode This pull request should be included in the VS Code extension's release notes labels Oct 16, 2024
@v010maaa
Copy link
Contributor Author

v010maaa commented Oct 16, 2024

if (a &&= something) case added
15710d7 6cfcc5b

Screenshot 2024-10-17 at 5 43 42

@v010maaa v010maaa requested a review from vinistock October 16, 2024 21:12
Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution!

@vinistock vinistock enabled auto-merge (squash) October 17, 2024 13:52
@vinistock vinistock merged commit 01a8ecf into Shopify:main Oct 17, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect highlighting for local variables in conditionals
2 participants