diff --git a/Sources/GRPCCodeGen/Internal/Renderer/TextBasedRenderer.swift b/Sources/GRPCCodeGen/Internal/Renderer/TextBasedRenderer.swift index fe7f038a6..9986164a9 100644 --- a/Sources/GRPCCodeGen/Internal/Renderer/TextBasedRenderer.swift +++ b/Sources/GRPCCodeGen/Internal/Renderer/TextBasedRenderer.swift @@ -70,6 +70,9 @@ final class StringCodeWriter { if nextWriteAppendsToLastLine && !lines.isEmpty { let existingLine = lines.removeLast() newLine = existingLine + line + } else if line.isEmpty { + // Skip indentation to avoid trailing whitespace on blank lines. + newLine = line } else { let indentation = Array(repeating: " ", count: self.indentation * level).joined() newLine = indentation + line diff --git a/Tests/GRPCCodeGenTests/Internal/Translator/ServerCodeTranslatorSnippetBasedTests.swift b/Tests/GRPCCodeGenTests/Internal/Translator/ServerCodeTranslatorSnippetBasedTests.swift index d2b0f624c..6afe4c3f4 100644 --- a/Tests/GRPCCodeGenTests/Internal/Translator/ServerCodeTranslatorSnippetBasedTests.swift +++ b/Tests/GRPCCodeGenTests/Internal/Translator/ServerCodeTranslatorSnippetBasedTests.swift @@ -408,7 +408,7 @@ final class ServerCodeTranslatorSnippetBasedTests: XCTestCase { request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse - + /// Documentation for outputStreamingMethod func outputStreaming( request: GRPCCore.StreamingServerRequest, @@ -452,7 +452,7 @@ final class ServerCodeTranslatorSnippetBasedTests: XCTestCase { request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.ServerResponse - + /// Documentation for outputStreamingMethod func outputStreaming( request: GRPCCore.ServerRequest, @@ -472,7 +472,7 @@ final class ServerCodeTranslatorSnippetBasedTests: XCTestCase { ) return GRPCCore.StreamingServerResponse(single: response) } - + internal func outputStreaming( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext