From 85fbbb5a3a0267cc330e2a2209d0363682087086 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Wed, 13 May 2026 12:01:10 -0400 Subject: [PATCH] Limit diff entry size to 1K --- .../com/jakewharton/diffuse/diff/ComponentDiff.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ComponentDiff.kt b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ComponentDiff.kt index ddf8773b..f7d0af9b 100644 --- a/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ComponentDiff.kt +++ b/reports/src/main/kotlin/com/jakewharton/diffuse/diff/ComponentDiff.kt @@ -56,14 +56,22 @@ internal fun StringBuilder.appendComponentDiff(name: String, diff: ComponentDiff ) if (diff.added.isNotEmpty()) { appendLine() - diff.added.forEach { appendLine("+ $it") } + diff.added.forEach { appendLine("+ ${it.toString().truncateTo(1024)}") } } if (diff.removed.isNotEmpty()) { appendLine() - diff.removed.forEach { appendLine("- $it") } + diff.removed.forEach { appendLine("- ${it.toString().truncateTo(1024)}") } } } .prependIndent(" ") ) } } + +private fun String.truncateTo(max: Int): String { + return if (length > max) { + substring(0, max) + '…' + } else { + this + } +}