Skip to content

iOS: explicit line breaks expand short text to maxWidth #990

Closed

Description

@Yash-Singh1

Short text separated by explicit line breaks reports the container's full available width on iOS. For example, one\ntwo in a content-sized view with a 300-point maximum width expands to 300 points even though both lines are short.

ENRMFinalizeMeasuredTextSize currently treats any second line fragment as wrapping. Explicit newlines, CRLF, and Unicode line/paragraph separators therefore trigger the same width pin as an actual soft wrap.

I propose pinning to maxWidth only when TextKit's next line starts without an explicit separator. This preserves the existing protection against rewrapping soft-wrapped content while allowing explicit breaks to retain their intrinsic width. The same helper is used by view-backed and view-free measurement.

Six native TextKit regression methods cover single-line text, explicit separators, trailing newlines, soft wrapping, soft wrapping after an explicit break, and emoji before a break. The original measurement code fails the explicit-break cases; the proposed change passes. The change was also verified in an iOS simulator through a consuming app. XCTest coverage is ready for the upstream example-app test target.

This is separate from the narrow wrapping reported in #517. The proposed fix addresses short explicit lines expanding to the full container width.

Generated by GPT 6.1 Sol using the Codex harness.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions