Skip to content

Commit f0077e7

Browse files
fix(mobile): wrap ellipsize lines for ktlint
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c9e2cb0 commit f0077e7

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • apps/mobile/modules/t3-review-diff/android/src/main/java/expo/modules/t3reviewdiff

‎apps/mobile/modules/t3-review-diff/android/src/main/java/expo/modules/t3reviewdiff/T3ReviewDiffView.kt‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,16 +1428,20 @@ private const val ELLIPSIZE_MAX_CHARS = 500
14281428

14291429
private fun ellipsize(value: String, paint: Paint, width: Float): String {
14301430
val truncated = value.length > ELLIPSIZE_MAX_CHARS
1431-
val text = if (truncated) value.substring(0, surrogateSafeEnd(value, ELLIPSIZE_MAX_CHARS)) else value
1431+
val capEnd = surrogateSafeEnd(value, ELLIPSIZE_MAX_CHARS)
1432+
val text = if (truncated) value.substring(0, capEnd) else value
14321433
if (!truncated && paint.measureText(text) <= width) return value
14331434
val suffix = "..."
14341435
val available = max(0f, width - paint.measureText(suffix))
14351436
val end = surrogateSafeEnd(text, paint.breakText(text, true, available, null))
14361437
return text.substring(0, end) + suffix
14371438
}
14381439

1439-
private fun surrogateSafeEnd(value: String, end: Int): Int =
1440-
if (end in 1 until value.length && Character.isSurrogatePair(value[end - 1], value[end])) end - 1 else end
1440+
private fun surrogateSafeEnd(value: String, end: Int): Int {
1441+
val splitsPair = end in 1 until value.length &&
1442+
Character.isSurrogatePair(value[end - 1], value[end])
1443+
return if (splitsPair) end - 1 else end
1444+
}
14411445

14421446
private fun indexFileHeaders(rows: List<DiffRow>): IntArray {
14431447
val headers = ArrayList<Int>()

0 commit comments

Comments
 (0)