Fix getUniformRun - #28014
Conversation
|
Hi! Thank you for opening this PR. Want me to review it? Based on the diff (117 lines, 4 files), I've queued these reviewers:
How this works
|
| --- | ||
| Formatted text uniform runs now account for optional formatting fields | ||
|
|
||
| `FormattedText.Members.getUniformRun` now ends a uniform run when an optional formatting field is present on only one side of a character boundary. |
There was a problem hiding this comment.
I'd link this, but our API docs site is not up to date and FormattedText is missing. Seems like its multiple releases out of date?
There was a problem hiding this comment.
I'll investigate this later today.
There was a problem hiding this comment.
Pull request overview
This PR fixes a comparison bug in buildNodeComparator that could treat nodes as equal even when their optional fields (or even node types) differ, which surfaced as incorrect behavior in FormattedText.Members.getUniformRun.
Changes:
- Update
buildNodeComparatorto compare node types and to reject nodes with additional/missing fields (fixing optional-field handling). - Add targeted unit tests covering optional formatting fields and comparator correctness for type/field mismatches.
- Add a changeset documenting the user-facing behavioral fix.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/dds/tree/src/feature-libraries/cursorComparator.ts | Fix comparator logic to account for type and optional/extra fields (hot-path optimized). |
| packages/dds/tree/src/test/feature-libraries/cursorComparator.spec.ts | Add regression tests for type mismatch and additional-field rejection. |
| packages/dds/tree/src/test/text/textDomainFormatted.spec.ts | Add regression test for getUniformRun behavior when optional format fields differ across a boundary. |
| .changeset/fix-formatted-text-uniform-runs.md | Document the behavior change in release notes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Bundle size comparisonBase commit: Pending — |
7781c1a
into
microsoft:main
Description
Fix a bug in buildNodeComparator where it mishandled optional fields.
This results in fixing a user facing bug in FormattedText.Members.getUniformRun.
Reviewer Guidance
The review process is outlined on this wiki page.