Skip to content

Fix string interpolated value extraction in val pattern #263

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

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ export const scalaTmLanguage: TmLanguage = {
}
},
{ // val x1[, x2, x3, ...] = y
match: `\\b(val)\\b\\s*${notStartOfComment}(${anyId}(?:\\s*,\\s*${anyId})*)?`,
match: `\\b(val)\\b\\s*${notStartOfComment}(${anyId}(?:\\s*,\\s*${anyId})*)?(?!\")`,
captures: {
'1': {
name: 'keyword.declaration.stable.scala'
Expand All @@ -826,7 +826,7 @@ export const scalaTmLanguage: TmLanguage = {
}
},
{ // var x1[, x2, x3, ...] = y
match: `\\b(var)\\b\\s*${notStartOfComment}(${anyId}(?:\\s*,\\s*${anyId})*)?`,
match: `\\b(var)\\b\\s*${notStartOfComment}(${anyId}(?:\\s*,\\s*${anyId})*)?(?!\")`,
captures: {
'1': {
name: 'keyword.declaration.volatile.scala'
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/#233.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SYNTAX TEST "source.scala"

"abc" match
case x"${x}b$y" =>
// ^ keyword.interpolation.scala
// ^ meta.template.expression.scala punctuation.definition.template-expression.begin.scala
// ^ meta.template.expression.scala punctuation.definition.template-expression.end.scala

val x"${x}b$y" = "abc"
// ^ keyword.interpolation.scala
// ^ meta.template.expression.scala punctuation.definition.template-expression.begin.scala
// ^ meta.template.expression.scala punctuation.definition.template-expression.end.scala

var x"${x}b$y" = "abc"
// ^ keyword.interpolation.scala
// ^ meta.template.expression.scala punctuation.definition.template-expression.begin.scala
// ^ meta.template.expression.scala punctuation.definition.template-expression.end.scala

val (x"${x}b$y", _) = "abc"
// ^ keyword.interpolation.scala
// ^ meta.template.expression.scala punctuation.definition.template-expression.begin.scala
// ^ meta.template.expression.scala punctuation.definition.template-expression.end.scala