Skip to content
Draft
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
150 changes: 150 additions & 0 deletions src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,90 @@ export const scalaTmLanguage: TmLanguage = {
},
name: 'string.quoted.triple.scala'
},
{
end: "'''(?!')",
begin: "'''(?=\\s*\\n)",
beginCaptures: {
'0': {
name: 'punctuation.definition.string.begin.scala'
}
},
patterns: [
{
match: '\\\\\\\\|\\\\u[0-9A-Fa-f]{4}',
name: 'constant.character.escape.scala'
}
],
endCaptures: {
'0': {
name: 'punctuation.definition.string.end.scala'
}
},
name: 'string.quoted.triple.scala'
},
{
end: "''''(?!')",
begin: "''''(?=\\s*\\n)",
beginCaptures: {
'0': {
name: 'punctuation.definition.string.begin.scala'
}
},
patterns: [
{
match: '\\\\\\\\|\\\\u[0-9A-Fa-f]{4}',
name: 'constant.character.escape.scala'
}
],
endCaptures: {
'0': {
name: 'punctuation.definition.string.end.scala'
}
},
name: 'string.quoted.triple.scala'
},
{
end: "'''''(?!')",
begin: "'''''(?=\\s*\\n)",
beginCaptures: {
'0': {
name: 'punctuation.definition.string.begin.scala'
}
},
patterns: [
{
match: '\\\\\\\\|\\\\u[0-9A-Fa-f]{4}',
name: 'constant.character.escape.scala'
}
],
endCaptures: {
'0': {
name: 'punctuation.definition.string.end.scala'
}
},
name: 'string.quoted.triple.scala'
},
{
end: "''''''(?!')",
begin: "''''''(?=\\s*\\n)",
beginCaptures: {
'0': {
name: 'punctuation.definition.string.begin.scala'
}
},
patterns: [
{
match: '\\\\\\\\|\\\\u[0-9A-Fa-f]{4}',
name: 'constant.character.escape.scala'
}
],
endCaptures: {
'0': {
name: 'punctuation.definition.string.end.scala'
}
},
name: 'string.quoted.triple.scala'
},
{
begin: `\\b(raw)(""")`,
end: `(""")(?!")|\\$\n|(\\$[^\\$"_{${letterChars}])`,
Expand Down Expand Up @@ -403,6 +487,39 @@ export const scalaTmLanguage: TmLanguage = {
}
}
},
{
begin: `\\b(raw)(''')(?=\\s*\\n)`,
end: `(''')(?!')|\\$\n|(\\$[^\\$'_{${letterChars}])`,
beginCaptures: {
'1': {
name: 'keyword.interpolation.scala'
},
'2': {
name: 'string.quoted.triple.interpolated.scala punctuation.definition.string.begin.scala'
}
},
patterns: [
{
match: "\\$[\\$']",
name: 'constant.character.escape.scala'
},
{
"include": "#string-interpolation"
},
{
match: '.',
name: 'string.quoted.triple.interpolated.scala'
}
],
endCaptures: {
'1': {
name: 'string.quoted.triple.interpolated.scala punctuation.definition.string.end.scala'
},
'2': {
name: 'invalid.illegal.unrecognized-string-escape.scala'
}
}
},
{
begin: `\\b(${interpolatorid})(""")`,
end: `(""")(?!")|\\$\n|(\\$[^\\$"_{${letterChars}])`,
Expand Down Expand Up @@ -436,6 +553,39 @@ export const scalaTmLanguage: TmLanguage = {
}
}
},
{
begin: `\\b(${interpolatorid})(''')(?=\\s*\\n)`,
end: `(''')(?!')|\\$\n|(\\$[^\\$'_{${letterChars}])`,
beginCaptures: {
'1': {
name: 'keyword.interpolation.scala'
},
'2': {
name: 'string.quoted.triple.interpolated.scala punctuation.definition.string.begin.scala'
}
},
patterns: [
{
"include": "#string-interpolation"
},
{
match: '\\\\\\\\|\\\\u[0-9A-Fa-f]{4}',
name: 'constant.character.escape.scala'
},
{
match: '.',
name: 'string.quoted.triple.interpolated.scala'
}
],
endCaptures: {
'1': {
name: 'string.quoted.triple.interpolated.scala punctuation.definition.string.end.scala'
},
'2': {
name: 'invalid.illegal.unrecognized-string-escape.scala'
}
}
},
{
end: '"',
begin: '"',
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/Scala.tmLanguage.json

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions tests/snap/dedented-strings.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
object DedentedStringLiterals {

// Triple single quote strings
val str1 = '''
Hello
World
'''

// Four single quote strings
val str2 = ''''
Nested
''' quotes
''''

// Five single quote strings
val str3 = '''''
More
'''' quotes
'''''

// Six single quote strings
val str4 = ''''''
Even more
''''' quotes
''''''

// Interpolated triple single quote strings
val name = "World"
val str5 = s'''
Hello $name
'''

// Raw triple single quote strings
val str6 = raw'''
Raw $name content
'''

// Custom interpolated triple single quote strings
val str7 = custom'''
Custom $name content
'''

// Make sure regular strings still work
val regular1 = """
Regular triple quotes
"""

val regular2 = "Regular double quotes"

// Edge case: mismatched delimiters should not close
val str8 = ''''
This has four quotes to open
''' but only three to close, so this should not end the string
This line should still be part of the string
''''

}
Loading