Skip to content

Comments

fix: rich text wrap width calculation issue#1394

Merged
yiiqii merged 1 commit intodevfrom
fix/rich-text-wrap-width
Feb 4, 2026
Merged

fix: rich text wrap width calculation issue#1394
yiiqii merged 1 commit intodevfrom
fix/rich-text-wrap-width

Conversation

@wumaolinmaoan
Copy link
Contributor

@wumaolinmaoan wumaolinmaoan commented Feb 4, 2026

Summary by CodeRabbit

  • Refactor

    • Simplified rich text rendering initialization flow.
    • Updated text wrapping and sizing computation logic.
  • Deprecation

    • RichTextLayout.setSize() is now deprecated; use maxTextWidth and maxTextHeight instead for setting layout dimensions.

@wumaolinmaoan wumaolinmaoan requested a review from yiiqii February 4, 2026 07:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

The pull request refactors the rich-text component's rendering initialization and simplifies the wrap strategy API. The protected renderText method is removed, delegating its logic to updateTexture. The scaleFactor parameter is eliminated from wrap strategy signatures and replaced with a hardcoded internal constant (0.1). The setSize method in RichTextLayout is marked as deprecated.

Changes

Cohort / File(s) Summary
Component Rendering Refactor
plugin-packages/rich-text/src/rich-text-component.ts
Replaced renderText(options) invocation with direct updateTexture() call during initialization. Removed the protected renderText method entirely, consolidating initialization and sizing logic into the texture update flow. Removed SCALE_FACTOR argument from strategy's computeLines call.
API Deprecation
plugin-packages/rich-text/src/rich-text-layout.ts
Added JSDoc deprecation note to setSize method, directing callers to use maxTextWidth and maxTextHeight instead. No functional changes to method implementation.
Strategy Interface Updates
plugin-packages/rich-text/src/strategies/rich-text-interfaces.ts
Removed scaleFactor: number parameter from RichWrapStrategy.computeLines() signature, altering the public interface contract for wrap strategy implementations.
Strategy Implementation Updates
plugin-packages/rich-text/src/strategies/wrap/rich-wrap-disabled.ts, plugin-packages/rich-text/src/strategies/wrap/rich-wrap-enabled.ts
Removed scaleFactor parameter from computeLines method signatures in both disabled and enabled wrap strategies. Introduced internal constant scaleFactor = 1 / 10 (0.1) to replace externally-provided parameter, hardcoding the scaling factor for width/height calculations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 The scales have shifted, yet stayed the same,
scaleFactor now claims a static name—
Removed from calls, embedded within,
renderText fades; new flows begin.
Simpler contracts, cleaner sight,
The refactor hops left, then right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly relates to the main change: removing scaleFactor from wrap strategy calculations and introducing a hardcoded constant to fix width calculation issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/rich-text-wrap-width

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yiiqii yiiqii changed the base branch from main to dev February 4, 2026 07:31
@yiiqii yiiqii merged commit c0a9488 into dev Feb 4, 2026
2 checks passed
@yiiqii yiiqii deleted the fix/rich-text-wrap-width branch February 4, 2026 07:32
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.

2 participants