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

This code is interpreted as a string/char when adding space for some reason. #204

Open
sol-vin opened this issue Dec 2, 2024 · 4 comments
Assignees
Labels

Comments

@sol-vin
Copy link

sol-vin commented Dec 2, 2024

Describe the bug
For some reason the following code creates a visual bug with the highlighting.

To Reproduce
Steps to reproduce the behavior:

  1. Type ty = (tile.index/width).to_i * tile_height
  2. Add a space like ty = (tile.index /width).to_i * tile_height
  3. Highlighting is broken

Expected behavior
Highlighting should not break.

Piece of Code
A piece of code to reproduce the problem

Screenshots
Video:
https://github.com/user-attachments/assets/2bd8d707-9ba1-4198-aa0a-c96a38fd885d

Desktop (please complete the following information):

  • OS: Windows
  • Crystal version: 1.13.2
  • This plugin version: v0.9.6

Additional context
None, other than changing the method name to anything other than index fixes it?

@sol-vin sol-vin added the bug label Dec 2, 2024
@sol-vin sol-vin changed the title This code is interpretted as a string/char for some reason. This code is interpreted as a string/char for some reason. Dec 2, 2024
@sol-vin sol-vin changed the title This code is interpreted as a string/char for some reason. This code is interpreted as a string/char when adding space for some reason. Dec 2, 2024
@nobodywasishere
Copy link
Member

nobodywasishere commented Dec 2, 2024

It's probably due to it considering that / to be the start of a regex and not being able to find the end. If you put a # / at the end of that line, is the error contained to that line?

I need to go through and re-do the syntax highlighting rules, or just figure out a way to do syntax highlighting in vscode with tree-sitter and do that instead (the latter being a lot less error prone, but harder to write)

@sol-vin
Copy link
Author

sol-vin commented Dec 2, 2024

Yep, highlighting unbreaks when commented out. However, this stops breaking when the method name index is changed to anything else

@sol-vin
Copy link
Author

sol-vin commented Dec 2, 2024

2024-12-01.20-17-49.mp4

@nobodywasishere
Copy link
Member

Using tree sitter does look possible, just requires the use of the semantic tokens API
https://marketplace.visualstudio.com/items?itemName=AlecGhost.tree-sitter-vscode

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

No branches or pull requests

2 participants