Skip to content

fix offset_to_line test failure#1055

Open
Third-Thing wants to merge 1 commit intolapce:mainfrom
Third-Thing:fix-failing-test
Open

fix offset_to_line test failure#1055
Third-Thing wants to merge 1 commit intolapce:mainfrom
Third-Thing:fix-failing-test

Conversation

@Third-Thing
Copy link
Copy Markdown
Contributor

@Third-Thing Third-Thing commented Mar 27, 2026

The test hardcoded expected vline numbers (4, 5) that assumed character d at offset 16 would land exactly at a soft wrap boundary at width 36px. Hypothesis: These values depended on specific font metrics from the pre-Parley text layout engine. After the Parley integration, SansSerif at 12pt renders with slightly different character widths, shifting the wrap point so d no longer starts a new visual line.

Rather than adjusting the magic numbers to match Parley's metrics (which would break again on the next layout engine or font change), the fix discovers the actual wrap boundaries at runtime and asserts the property the test was always meant to verify: at a soft wrap boundary, Forward affinity resolves to the next visual line and Backward resolves to the previous one. A guard assertion ensures the test fixture still produces at least one soft wrap, so it can't pass vacuously.

@Third-Thing Third-Thing changed the title fix offset_to_line test failure after Parley integration fix offset_to_line test failure Mar 28, 2026
@Third-Thing
Copy link
Copy Markdown
Contributor Author

Third-Thing commented Mar 28, 2026

On second glance it looks like the Parley PR added tests, so probably didn't miss a failing one.

Another potential cause could be ec9024f changing two things that directly affect wrapping in the test:

  1. Wrap mode: Wrap::WordTextWrapMode::Wrap + OverflowWrap::BreakWord
  2. Call order: the old code set wrap mode before set_text(); the new code calls set_text() first, then applies wrap settings after

The test hardcoded expected vline numbers (`4`, `5`) that assumed
character `d` at offset 16 would land exactly at a soft wrap boundary
at width 36px.

The fix discovers the actual wrap boundaries at runtime
and asserts the property the test was always meant to verify:
at a soft wrap boundary, `Forward` affinity resolves to the next
visual line and `Backward` resolves to the previous one.
A guard assertion ensures the test fixture still produces
at least one soft wrap, so it can't pass vacuously.
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