Skip to content

Commit

Permalink
Merge pull request #263 from nicolasstucki/fix-233-2
Browse files Browse the repository at this point in the history
Fix string interpolated value extraction in val pattern
  • Loading branch information
nicolasstucki authored Oct 18, 2023
2 parents 5a6ac96 + 84a2a80 commit 27315cb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
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

0 comments on commit 27315cb

Please sign in to comment.