Skip to content

Commit

Permalink
C#: Fixed adjacent string interpolations (#2402)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Jun 7, 2020
1 parent 939a17c commit 2a2e79e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/prism-csharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
function createInterpolationInside(interpolation, interpolationRound) {
return {
'interpolation': {
pattern: re(/([^{](?:\{\{)*)<<0>>/.source, [interpolation]),
pattern: re(/((?:^|[^{])(?:\{\{)*)<<0>>/.source, [interpolation]),
lookbehind: true,
inside: {
'format-string': {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-csharp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions tests/languages/csharp/interpolation-string_feature.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$"Hello, {{ {name} }}! Today is {date.DayOfWeek}, it's {date:HH:mm} now."
$"{a,5} and {b + "" /* foo ":} */:format} {h(a, b)}"
$"{1}{2}{3}"

@$"
"
Expand Down Expand Up @@ -87,6 +88,31 @@ $@"{
]],
["string", "\""]
]],
["interpolation-string", [
["string", "$\""],
["interpolation", [
["punctuation", "{"],
["expression", [
["number", "1"]
]],
["punctuation", "}"]
]],
["interpolation", [
["punctuation", "{"],
["expression", [
["number", "2"]
]],
["punctuation", "}"]
]],
["interpolation", [
["punctuation", "{"],
["expression", [
["number", "3"]
]],
["punctuation", "}"]
]],
["string", "\""]
]],
["interpolation-string", [
["string", "@$\"\n\""]
]],
Expand Down

0 comments on commit 2a2e79e

Please sign in to comment.