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 + } +}