Skip to content

Commit bdd18ee

Browse files
Merge pull request #261 from nicolasstucki/fix-260
Highlight `'''` as single quote character literal
2 parents d903641 + 806a87a commit bdd18ee

File tree

2 files changed

+55
-26
lines changed

2 files changed

+55
-26
lines changed

src/typescript/Scala.tmLanguage.ts

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -883,37 +883,53 @@ export const scalaTmLanguage: TmLanguage = {
883883
]
884884
},
885885
'char-literal': {
886-
end: "'|$",
887-
begin: "'",
888-
beginCaptures: {
889-
'0': {
890-
name: 'punctuation.definition.character.begin.scala'
891-
}
892-
},
893886
patterns: [
894887
{
895-
match: `\\\\(?:[btnfr\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})`,
896-
name: 'constant.character.escape.scala'
897-
},
898-
{
899-
match: '\\\\.',
900-
name: 'invalid.illegal.unrecognized-character-escape.scala'
901-
},
902-
{
903-
match: "[^']{2,}",
904-
name: 'invalid.illegal.character-literal-too-long'
888+
match: "(')'(')",
889+
name: 'string.quoted.other constant.character.literal.scala',
890+
captures: {
891+
'1': {
892+
name: 'punctuation.definition.character.begin.scala'
893+
},
894+
'2': {
895+
name: 'punctuation.definition.character.end.scala'
896+
}
897+
}
905898
},
906899
{
907-
match: "(?<!')[^']",
908-
name: 'invalid.illegal.character-literal-too-long'
909-
}
910-
],
911-
endCaptures: {
912-
'0': {
913-
name: 'punctuation.definition.character.end.scala'
900+
end: "'|$",
901+
begin: "'",
902+
beginCaptures: {
903+
'0': {
904+
name: 'punctuation.definition.character.begin.scala'
905+
}
906+
},
907+
patterns: [
908+
{
909+
match: `\\\\(?:[btnfr\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})`,
910+
name: 'constant.character.escape.scala'
911+
},
912+
{
913+
match: '\\\\.',
914+
name: 'invalid.illegal.unrecognized-character-escape.scala'
915+
},
916+
{
917+
match: "[^']{2,}",
918+
name: 'invalid.illegal.character-literal-too-long'
919+
},
920+
{
921+
match: "(?<!')[^']",
922+
name: 'invalid.illegal.character-literal-too-long'
923+
},
924+
],
925+
endCaptures: {
926+
'0': {
927+
name: 'punctuation.definition.character.end.scala'
928+
}
929+
},
930+
name: 'string.quoted.other constant.character.literal.scala'
914931
}
915-
},
916-
name: 'string.quoted.other constant.character.literal.scala'
932+
]
917933
},
918934
initialization: {
919935
match: '\\b(new)\\b',

tests/unit/#260.test.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SYNTAX TEST "source.scala"
2+
3+
val x = ''' + '"'
4+
// ^^^ constant.character.literal.scala
5+
// ^ punctuation.definition.character.begin.scala
6+
// ^ punctuation.definition.character.end.scala
7+
// ^ keyword.operator.arithmetic.scala
8+
9+
val x = '''' + '"'
10+
// ^^^^ constant.character.literal.scala
11+
// ^ punctuation.definition.character.begin.scala
12+
// ^ punctuation.definition.character.end.scala
13+
// ^ punctuation.definition.character.begin.scala

0 commit comments

Comments
 (0)