Skip to content

Implement line limit APIs - #958

Merged
Kyle-Ye merged 2 commits into
mainfrom
feature/line_limit
Jul 31, 2026
Merged

Implement line limit APIs#958
Kyle-Ye merged 2 commits into
mainfrom
feature/line_limit

Conversation

@Kyle-Ye

@Kyle-Ye Kyle-Ye commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

  • implement optional, ranged, and reserved-space lineLimit overloads
  • propagate upper and lower line limits through EnvironmentValues
  • add DocC documentation and focused unit coverage for modifier layout and environment behavior

This completes the line-limit API surface and lets text layout receive both minimum and maximum line constraints through the environment.

@github-actions github-actions Bot added area: data-flow State, binding, environment, preference, observation, or property data flow. area: tests Test suites, UI tests, fixtures, snapshots, and test support code. area: text Text, labels, line style, and text rendering APIs. type: feature New API, behavior, platform support, or user-facing capability. labels Jul 31, 2026
@Kyle-Ye
Kyle-Ye marked this pull request as ready for review July 31, 2026 15:50
@Kyle-Ye
Kyle-Ye merged commit dd6eeb0 into main Jul 31, 2026
7 of 8 checks passed
@Kyle-Ye
Kyle-Ye deleted the feature/line_limit branch July 31, 2026 15:50
@augmentcode

augmentcode Bot commented Jul 31, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Completes OpenSwiftUI’s line-limit API surface and propagates both minimum and maximum line constraints through the environment so text layout can honor them.

Changes:

  • Added LineLimits.swift with View.lineLimit overloads for optional limits, ranged limits, and the reservesSpace variant.
  • Introduced LineLimitModifier as an EnvironmentModifier to write both lineLimit (max) and lowerLineLimit (min).
  • Relocated EnvironmentValues.lineLimit/lowerLineLimit from Text+View.swift into the dedicated line-limits file.
  • Added focused unit tests covering overload wiring, environment writes, and modifier layout characteristics.

Technical Notes: Ranged and space-reserving APIs now flow min/max constraints via EnvironmentValues for downstream Text/TextField layout behavior.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

/// instances display.
@inlinable
nonisolated public func lineLimit(_ number: Int?) -> some View {
environment(\.lineLimit, number)

@augmentcode augmentcode Bot Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lineLimit(_ number: Int?) only writes EnvironmentValues.lineLimit; if an ancestor sets lowerLineLimit (via range/reservesSpace overloads), this overload will leave the old minimum in place, which can unexpectedly reserve/require extra lines. Consider ensuring this overload also resets the lower bound when setting/clearing the max.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

/// line in the ``Text`` element to the 2 lines that fit within the view's
/// bounds:
///
/// Text("This is a long string that demonstrates the effect of OpenSwiftUI's lineLimit(:_) operator.")

@augmentcode augmentcode Bot Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This DocC example text references lineLimit(:_), but the actual signature is lineLimit(_:); this looks like a symbol-typo that may break generated linking/searchability.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 26.78%. Comparing base (21eebc9) to head (9b09035).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #958      +/-   ##
==========================================
+ Coverage   26.72%   26.78%   +0.06%     
==========================================
  Files         731      732       +1     
  Lines       52738    52771      +33     
==========================================
+ Hits        14094    14136      +42     
+ Misses      38644    38635       -9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

area: data-flow State, binding, environment, preference, observation, or property data flow. area: tests Test suites, UI tests, fixtures, snapshots, and test support code. area: text Text, labels, line style, and text rendering APIs. type: feature New API, behavior, platform support, or user-facing capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant