Don't force multiline interpolation into a single line (#1280)

Also, fixes an issue where forced single-line formatting would break for if/else
and let expressions

---------

Co-authored-by: Islon Scherer <islonscherer@gmail.com>
This commit is contained in:
Daniel Chao
2025-10-31 10:47:53 -07:00
committed by GitHub
parent ffc9167bf5
commit ea778a7e7a
5 changed files with 69 additions and 16 deletions

View File

@@ -13,7 +13,7 @@ prop3 =
\(new {
// some comment
foo = 1
// some comment
bar = 2
})
@@ -49,3 +49,28 @@ prop7 = "\(
)"
prop8 = "\(new { foo = 1 bar = 2 baz = 3 })"
prop9 = "\(if (true) 1 else 2)"
prop10 = "\(
if (true) 1
else 2
)"
prop11 = "\(
new {
1;
2;
3;
}
)"
// single line expressions are not broken up
prop12 = "Some \(if (true) 1 else 2) reeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaallly long string with interpolation"
// multi-line expressions are preserved
prop13 = "Some \(
if (true)
1
else 2
) reeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaallly long string with interpolation"

View File

@@ -1,6 +1,8 @@
foo =
"""
asd \(new { bar = 1 }) asd
asd \(new {
bar = 1
}) asd
"""
bar =

View File

@@ -50,3 +50,29 @@ prop7 =
)"
prop8 = "\(new { foo = 1; bar = 2; baz = 3 })"
prop9 = "\(if (true) 1 else 2)"
prop10 =
"\(if (true)
1
else
2)"
prop11 =
"\(new {
1
2
3
})"
// single line expressions are not broken up
prop12 =
"Some \(if (true) 1 else 2) reeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaallly long string with interpolation"
// multi-line expressions are preserved
prop13 =
"Some \(if (true)
1
else
2) reeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaallly long string with interpolation"