Skip to content
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
12 changes: 10 additions & 2 deletions grammars/julia.cson
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ repository:
name: 'punctuation.definition.string.end.julia'
patterns: [
{
include: '#string_escaped_char'
include: '#string_escaped_char_raw'
}
]
}
Expand All @@ -570,7 +570,7 @@ repository:
name: 'punctuation.definition.string.end.julia'
patterns: [
{
include: '#string_escaped_char'
include: '#string_escaped_char_raw'
}
]
}
Expand Down Expand Up @@ -829,6 +829,14 @@ repository:
name: 'constant.character.escape.julia'
}
]
string_escaped_char_raw:
comment: 'In raw strings only a backslash that escapes a quote (or another backslash) is meaningful; all other backslashes are literal.'
patterns: [
{
match: '\\\\(\\\\|")'
name: 'constant.character.escape.julia'
}
]
string_dollar_sign_interpolate:
patterns: [
{
Expand Down
13 changes: 11 additions & 2 deletions grammars/julia.json
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@
},
"patterns": [
{
"include": "#string_escaped_char"
"include": "#string_escaped_char_raw"
}
]
},
Expand All @@ -656,7 +656,7 @@
},
"patterns": [
{
"include": "#string_escaped_char"
"include": "#string_escaped_char_raw"
}
]
},
Expand Down Expand Up @@ -970,6 +970,15 @@
}
]
},
"string_escaped_char_raw": {
"comment": "In raw strings only a backslash that escapes a quote (or another backslash) is meaningful; all other backslashes are literal.",
"patterns": [
{
"match": "\\\\(\\\\|\")",
"name": "constant.character.escape.julia"
}
]
},
"string_dollar_sign_interpolate": {
"patterns": [
{
Expand Down
13 changes: 11 additions & 2 deletions template/julia.json
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@
},
"patterns": [
{
"include": "#string_escaped_char"
"include": "#string_escaped_char_raw"
}
]
},
Expand All @@ -656,7 +656,7 @@
},
"patterns": [
{
"include": "#string_escaped_char"
"include": "#string_escaped_char_raw"
}
]
},
Expand Down Expand Up @@ -970,6 +970,15 @@
}
]
},
"string_escaped_char_raw": {
"comment": "In raw strings only a backslash that escapes a quote (or another backslash) is meaningful; all other backslashes are literal.",
"patterns": [
{
"match": "\\\\(\\\\|\")",
"name": "constant.character.escape.julia"
}
]
},
"string_dollar_sign_interpolate": {
"patterns": [
{
Expand Down
42 changes: 42 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3761,6 +3761,48 @@ describe('Julia grammar', function () {
},
])
})
it("does not tokenize non-quote backslash sequences in raw strings", function () {
const tokens = tokenize(grammar, 'raw"\\textbf"')
compareTokens(tokens, [
{
value: 'raw',
scopes: ["string.quoted.other.julia", "support.function.macro.julia"]
},
{
value: '"',
scopes: ["string.quoted.other.julia", "punctuation.definition.string.begin.julia"]
},
{
value: '\\textbf',
scopes: ["string.quoted.other.julia"]
},
{
value: '"',
scopes: ["string.quoted.other.julia", "punctuation.definition.string.end.julia"]
},
])
})
it("does not tokenize non-quote backslash sequences in raw multiline strings", function () {
const tokens = tokenize(grammar, 'raw"""\\textbf"""')
compareTokens(tokens, [
{
value: 'raw',
scopes: ["string.quoted.other.julia", "support.function.macro.julia"]
},
{
value: '"""',
scopes: ["string.quoted.other.julia", "punctuation.definition.string.begin.julia"]
},
{
value: '\\textbf',
scopes: ["string.quoted.other.julia"]
},
{
value: '"""',
scopes: ["string.quoted.other.julia", "punctuation.definition.string.end.julia"]
},
])
})
it("tokenizes escape codes in var strings", function () {
const tokens = tokenize(grammar, 'var"a\\"b"')
compareTokens(tokens, [
Expand Down
13 changes: 11 additions & 2 deletions variants/julia_vscode.json
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@
},
"patterns": [
{
"include": "#string_escaped_char"
"include": "#string_escaped_char_raw"
}
]
},
Expand All @@ -656,7 +656,7 @@
},
"patterns": [
{
"include": "#string_escaped_char"
"include": "#string_escaped_char_raw"
}
]
},
Expand Down Expand Up @@ -970,6 +970,15 @@
}
]
},
"string_escaped_char_raw": {
"comment": "In raw strings only a backslash that escapes a quote (or another backslash) is meaningful; all other backslashes are literal.",
"patterns": [
{
"match": "\\\\(\\\\|\")",
"name": "constant.character.escape.julia"
}
]
},
"string_dollar_sign_interpolate": {
"patterns": [
{
Expand Down
Loading