Skip to content

Conversation

@BryanValverdeU
Copy link
Contributor

If there are more than 2 format parsers, we call internalTextProcessor more than once, which causes that we add more segments into the model.

To fix move the internalTextProcessor function call outside of the for loop

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where multiple text format parsers caused duplicate text segments to be added to the model. The fix moves the internalTextProcessor call outside the forEach loop so it's only called once after all parsers have modified the segment format.

Changes:

  • Moved internalTextProcessor call outside the forEach loop in textProcessor.ts to prevent duplicate segment creation
  • Added three new test cases to verify correct behavior with multiple parsers, empty parser arrays, and parsers that modify the segment format

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/roosterjs-content-model-dom/lib/domToModel/processors/textProcessor.ts Fixed bug by moving internalTextProcessor call outside the parser loop
packages/roosterjs-content-model-dom/test/domToModel/processors/textProcessorTest.ts Added comprehensive test coverage for multiple parsers scenario and edge cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@BryanValverdeU BryanValverdeU enabled auto-merge (squash) January 19, 2026 15:53
@BryanValverdeU BryanValverdeU merged commit f3eef62 into master Jan 19, 2026
7 checks passed
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.

3 participants