Repository navigation
fix: correct TextMate grammar badly highlighting lemire.gr - #186
Open
Kara-Zor-El wants to merge 1 commit into
Open
Kara-Zor-El wants to merge 1 commit into
Kara-Zor-El wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Breakdown
The syntax highlighting seems to get messed up because our textmate grammar specifies blocks as anything appearing after
=>,)or anelse. and records as any other combination of{ <body> }. When we use an inline block likelet x = { 1 }inlemire.grit gets treated as a record and because there was ause WasmI32.{ (+), (-) }statement inside a match block which gets incorrectly parsed closing the parent record causing the highlighting for the rest of the file to be off.Fix
The fix I implemented for this was to allow expressions to occur in records for the sake of syntax highlighting as it was a quick way of fixing the problem with no major downsides.
Correct Fix
We should revisit this in the future, and probably make a broader construct for
{ <body> }which can either contain a record disambiguated by weather the first thing inside is a field or record spread, or an expression.Alternatively a simpler approach less correct to our grain grammar but correct enough for textmate would be to just make everything blocks and allow both record spreads and record fields in blocks. While this wouldn't be correct we don't exactly highlight records as a whole so it shouldn't be noticeable to users.
closes: #152