Skip to content

Fix TextDiff layout parity and add performance baselines#4

Merged
iSapozhnik merged 8 commits intomainfrom
bugfix/width-and-height-diff
Feb 23, 2026
Merged

Fix TextDiff layout parity and add performance baselines#4
iSapozhnik merged 8 commits intomainfrom
bugfix/width-and-height-diff

Conversation

@iSapozhnik
Copy link
Owner

@iSapozhnik iSapozhnik commented Feb 23, 2026

Summary

  • fix TextDiff width drift by improving token layout measurement and incremental line width handling
  • tighten multiline text layout parity with SwiftUI/AppKit text rendering behavior
  • convert snapshot suites to XCTestCase and configure snapshot artifact output
  • add XCTest performance benchmarks for 200/500/1000-word layout cases
  • update snapshot references and include performance baselines

Notes

  • snapshot artifacts are configured under .snapshot-artifacts/ (gitignored)
  • branch includes updated snapshot reference images reflecting the new layout behavior

Enhance `measuredTextSize` to include a `linePrefix` parameter, improving
text measurement accuracy, especially for wrapping cases. Introduce
`measuredIncrementalWidth` to calculate text width incrementally. These changes
ensure that text layout calculations account for prefix widths, making soft-wrap
decisions more precise. This update addresses inconsistencies in text dimension
calculations when different font attributes are applied.
Add baseline Performance tests for `TextDiffTests` to measure the
layout performance for different word counts. This helps in tracking
performance regressions over time. The baselines are configured for
1000, 500, and 200 words tests and are set for a local Apple M1
environment to standardize performance metrics.
Replace `measuredTextSize` with `measuredIncrementalTextWidth` to improve
performance by calculating text width incrementally using an
`NSMutableString`. This reduces redundant calculations and enhances
efficiency in handling large text segments, particularly when soft-wrapping
text. Additionally, store widths for reuse and keep track of combined
line width to minimize repeated layout operations, resulting in smoother
and faster text rendering.
Increase text size from 16 to 32 in the "Height diff" preview
to enhance readability. Change "!" to "." for consistent
punctuation in the "Punctuation Replacement" preview. These
changes improve the design aesthetics and maintain
consistency in visual presentations.
Add `DiffLayouterPerformanceTests.swift` to test text layout
performance with varying word counts. Convert existing snapshot tests
to use XCTest, enhancing compatibility and extendability. Introduce
snapshot artifacts directory configuration to manage artifacts. Update
tests to specify the snapshot test name explicitly. Modify
`verticalInsetIsNonNegativeAndMonotonic` test to ensure non-negativity
and check monotonicity of vertical insets, improving test rigor.
@iSapozhnik
Copy link
Owner Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca10965e37

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Repository owner deleted a comment from chatgpt-codex-connector bot Feb 23, 2026
@iSapozhnik iSapozhnik merged commit eabfa87 into main Feb 23, 2026
2 checks passed
@iSapozhnik iSapozhnik deleted the bugfix/width-and-height-diff branch February 23, 2026 21:53
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