-
Notifications
You must be signed in to change notification settings - Fork 37
Fix #226: Parse quoted blocks with spaces (' {
)
#227
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
Conversation
69c8e35
to
b3d1903
Compare
@@ -678,11 +678,11 @@ export const scalaTmLanguage: TmLanguage = { | |||
'scala-quoted': { | |||
patterns: [ | |||
{ // Start of `'{ .. }` or `${ .. }` | |||
match: "['$]\\{(?!')", | |||
match: "['$][ \\t]*\\{(?!')", |
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.
I used [ \\t]
instead of \\b
because the Scala compiler doesn't accept newlines here.
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.
A single rule that captures the '
or $
but not rest.
{
match: "['$](?=[ \\t]*[{[](?!'))"
name: "..." // not sure what this should be
// maybe "escape.scala" like in string interpolators
}
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.
Could also take any space characters
match: "['$](?=\\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.
To be more precise
match: "['$](?=[{[](?!')|\\s+[{[])"
as it is valid to have ${'{...}}
even though a warning will be emitted
@@ -5,11 +5,21 @@ | |||
// ^ constant.numeric.scala | |||
// ^ punctuation.section.block.end.scala | |||
|
|||
' { 2 } |
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.
Here I added both a tab and a space to cover the handling of tab characters I have in the code.
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.
Looks good! We had the same issue recently in Scalameta parser.
That does not seem right. I believe that the syntax requires the quote to be immediately followed by a curly brace. I will double check. |
It doesn't actually. At least last time I checked it did compile with whitespaces :O |
Indeed. I opened an issue to fix this in scala/scala3#13951. For ' { 2 }
' [ String ] it looks like the current highlighting is correct for both Scala 2 and Scala 3 (after bug fix) as it is an unclosed |
Thank you @nicolasstucki for fixing the underlying issue :) |
@nicolasstucki should we reopen this PR since it turns out it's a correct behaviour? |
I'm reopening since the compiler is not changing behavior. |
This is still missing some cases, see and other comments in that thread #227 (comment) |
This was fixed in #250 |
Fixes the linked issue.