Skip to content

fix(android): pin TextView line-breaking to match measurement [SUP-1472]#5

Open
xindixu wants to merge 1 commit into
feat/superapp-dist-0423from
feat/superapp-dist-0708
Open

fix(android): pin TextView line-breaking to match measurement [SUP-1472]#5
xindixu wants to merge 1 commit into
feat/superapp-dist-0423from
feat/superapp-dist-0708

Conversation

@xindixu

@xindixu xindixu commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Description

On Android, long / citation-heavy markdown messages were rendered truncated — the last paragraph(s) clipped — while identical content rendered in full on iOS and Web.

Root cause: a measure-vs-render line-breaking mismatch. MeasurementStore builds a StaticLayout that sets breakStrategy = HIGH_QUALITY only on API 29+ and leaves hyphenationFrequency at the default (NONE). The rendered TextView (setupAsMarkdownTextView) set neither, so it fell back to platform defaults (hyphenation enabled; HIGH_QUALITY even below API 29). The two paths wrapped text differently, so the rendered text used more lines than the measured height reserved for the view — and since a TextView clips overflow instead of scrolling, the tail was cut off. Same class of bug as the earlier Android width-clipping fix, on the line-breaking axis.

Technical detail

  • utils/text/view/TextViewSetup.kt: pin the rendered TextView to BREAK_STRATEGY_HIGH_QUALITY + HYPHENATION_FREQUENCY_NONE on API 23+ (covers both EnrichedMarkdownText and EnrichedMarkdownInternalText, which share this setup).
  • MeasurementStore.kt: extract applyMarkdownLineBreaking() and apply it to all three StaticLayout builders, extending the same settings down to API 23 (previously HIGH_QUALITY was set only on API 29+, so on API 23–28 measurement used SIMPLE while the TextView rendered HIGH_QUALITY).

Result: measure == render on every API level.

Test Plan

  • Rebuilt the Android app; the previously-truncated citation-heavy message now renders in full, matching iOS and Web.
  • Spot-check other markdown (headings, lists, tables, code blocks, long links) for correct height on Android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant