Skip to content

Commit 114a2a8

Browse files
committed
fixed the issue that the leading trivia is lost after string interpolation conversion
1 parent e4cb1bd commit 114a2a8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Sources/SourceKitLSP/Swift/CodeActions/ConvertStringConcatenationToStringInterpolation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct ConvertStringConcatenationToStringInterpolation: SyntaxRefactoringProvide
5656
[
5757
ExprSyntax(
5858
StringLiteralExprSyntax(
59+
leadingTrivia: syntax.leadingTrivia,
5960
openingPounds: commonPounds,
6061
openingQuote: .stringQuoteToken(),
6162
segments: segments,

Tests/SourceKitLSPTests/CodeActionTests.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,9 @@ final class CodeActionTests: XCTestCase {
10091009
func testConvertStringConcatenationToStringInterpolation() async throws {
10101010
try await assertCodeActions(
10111011
#"""
1012-
1️⃣#"["# + 2️⃣key + ": \(3️⃣d) " + 4️⃣value + ##"]"##5️⃣
1012+
1️⃣
1013+
#"["# + 2️⃣key + ": \(3️⃣d) " + 4️⃣value + ##"]"##5️⃣
1014+
10131015
"""#,
10141016
ranges: [("1️⃣", "2️⃣"), ("3️⃣", "4️⃣"), ("1️⃣", "5️⃣")],
10151017
exhaustive: false
@@ -1024,6 +1026,7 @@ final class CodeActionTests: XCTestCase {
10241026
TextEdit(
10251027
range: positions["1️⃣"]..<positions["5️⃣"],
10261028
newText: ###"""
1029+
10271030
##"[\##(key): \##(d) \##(value)]"##
10281031
"""###
10291032
)

0 commit comments

Comments
 (0)