From 2a64797c1a801a487ba4fe100b44c56817c8604c Mon Sep 17 00:00:00 2001 From: Karan Date: Wed, 7 Jan 2026 03:22:19 +0530 Subject: [PATCH] Add more edge cases --- .../ConvertJSONToCodableStruct.swift | 5 +- .../SyntaxRefactorTests.swift | 76 +++++++++++++++---- 2 files changed, 66 insertions(+), 15 deletions(-) diff --git a/Sources/SwiftLanguageService/CodeActions/ConvertJSONToCodableStruct.swift b/Sources/SwiftLanguageService/CodeActions/ConvertJSONToCodableStruct.swift index 99d3fa0b..69a1eb2a 100644 --- a/Sources/SwiftLanguageService/CodeActions/ConvertJSONToCodableStruct.swift +++ b/Sources/SwiftLanguageService/CodeActions/ConvertJSONToCodableStruct.swift @@ -110,9 +110,10 @@ package struct ConvertJSONToCodableStruct: EditRefactoringProvider { let baseIndentation = getBaseIndentation(from: jsonNode) let format = BasicFormat(indentationWidth: indentation, initialIndentation: baseIndentation) - let indentedDecls = topLevelObject.asDeclSyntax(name: "JSONValue") + var formattedDecls = topLevelObject.asDeclSyntax(name: "JSONValue") .formatted(using: format) - .description + formattedDecls.leadingTrivia = [] + let indentedDecls = formattedDecls.description // Render the change into a set of source edits. switch preflight { diff --git a/Tests/SourceKitLSPTests/SyntaxRefactorTests.swift b/Tests/SourceKitLSPTests/SyntaxRefactorTests.swift index 637cdeac..80c49b02 100644 --- a/Tests/SourceKitLSPTests/SyntaxRefactorTests.swift +++ b/Tests/SourceKitLSPTests/SyntaxRefactorTests.swift @@ -202,22 +202,22 @@ final class SyntaxRefactorTests: SourceKitLSPTestCase { range: AbsolutePosition(utf8Offset: 0)..(