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

🪲Variable is not highlighted if followed by an exclamation mark #5089

Closed
jpelay opened this issue Feb 8, 2024 · 2 comments · Fixed by #5480
Closed

🪲Variable is not highlighted if followed by an exclamation mark #5089

jpelay opened this issue Feb 8, 2024 · 2 comments · Fixed by #5480
Labels
bug Something isn't working

Comments

@jpelay
Copy link
Member

jpelay commented Feb 8, 2024

Describe the bug
On level 2 if a variable if followed by an exclamation mark it is still valid, and the syntax highlighter it should reflect this:

image

@jpelay jpelay added the bug Something isn't working label Feb 8, 2024
@juliabolt
Copy link
Collaborator

shouldn't the output be Hedy is name! since name! is another string than name ? or do we definitely want variables to be replaced with their values? If so, I agree the syntax highlighter should reflect this.

@Felienne
Copy link
Member

shouldn't the output be Hedy is name! since name! is another string than name ? or do we definitely want variables to be replaced with their values? If so, I agree the syntax highlighter should reflect this.

That is a great point but that shows you think like a programmer haha! We thought that for a kid this behaviour makes sense (and thus it should be highlighted)

@mergify mergify bot closed this as completed in #5480 Apr 29, 2024
mergify bot pushed a commit that referenced this issue Apr 29, 2024
)

This PR addresses a syntax highlighting issue in Level 2.
 Previously, if an exclamation mark followed a variable, it was still considered valid, but the syntax highlighter did not reflect this correctly.

For instance, in the command: 
`
name is Hedy print name is name
`
The keyword **name** was highlighted in blue in all occurrences. However, if an exclamation mark was added to the end of the command:
`name is Hedy print name is name!
`
The keyword **name** was only highlighted in blue in the first occurrence.

To resolve this issue, I have introduced a SpecialChar token to the grammar file. 
This token includes an exclamation mark (!), question mark (?), and period (.) characters.
 With this change, the syntax highlighter correctly recognizes and highlights the variable name even when a special character follows it.

Fixes #5089 

**How to test**

Follow these steps to verify this PR works as intended:

* Go to http://localhost:8080/hedy/2#is_command
* Type:
```
name is Hedy 
print name is name!
```
* Check that name is highlighted in all occurences
![image](https://github.com/hedyorg/hedy/assets/65734671/e93f3271-bdaa-4af5-9a91-0d869908b22b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

3 participants