Skip to content

Commit 27315cb

Browse files
Merge pull request #263 from nicolasstucki/fix-233-2
Fix string interpolated value extraction in val pattern
2 parents 5a6ac96 + 84a2a80 commit 27315cb

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/typescript/Scala.tmLanguage.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ export const scalaTmLanguage: TmLanguage = {
815815
}
816816
},
817817
{ // val x1[, x2, x3, ...] = y
818-
match: `\\b(val)\\b\\s*${notStartOfComment}(${anyId}(?:\\s*,\\s*${anyId})*)?`,
818+
match: `\\b(val)\\b\\s*${notStartOfComment}(${anyId}(?:\\s*,\\s*${anyId})*)?(?!\")`,
819819
captures: {
820820
'1': {
821821
name: 'keyword.declaration.stable.scala'
@@ -826,7 +826,7 @@ export const scalaTmLanguage: TmLanguage = {
826826
}
827827
},
828828
{ // var x1[, x2, x3, ...] = y
829-
match: `\\b(var)\\b\\s*${notStartOfComment}(${anyId}(?:\\s*,\\s*${anyId})*)?`,
829+
match: `\\b(var)\\b\\s*${notStartOfComment}(${anyId}(?:\\s*,\\s*${anyId})*)?(?!\")`,
830830
captures: {
831831
'1': {
832832
name: 'keyword.declaration.volatile.scala'

tests/unit/#233.test.scala

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SYNTAX TEST "source.scala"
2+
3+
"abc" match
4+
case x"${x}b$y" =>
5+
// ^ keyword.interpolation.scala
6+
// ^ meta.template.expression.scala punctuation.definition.template-expression.begin.scala
7+
// ^ meta.template.expression.scala punctuation.definition.template-expression.end.scala
8+
9+
val x"${x}b$y" = "abc"
10+
// ^ keyword.interpolation.scala
11+
// ^ meta.template.expression.scala punctuation.definition.template-expression.begin.scala
12+
// ^ meta.template.expression.scala punctuation.definition.template-expression.end.scala
13+
14+
var x"${x}b$y" = "abc"
15+
// ^ keyword.interpolation.scala
16+
// ^ meta.template.expression.scala punctuation.definition.template-expression.begin.scala
17+
// ^ meta.template.expression.scala punctuation.definition.template-expression.end.scala
18+
19+
val (x"${x}b$y", _) = "abc"
20+
// ^ keyword.interpolation.scala
21+
// ^ meta.template.expression.scala punctuation.definition.template-expression.begin.scala
22+
// ^ meta.template.expression.scala punctuation.definition.template-expression.end.scala

0 commit comments

Comments
 (0)