Skip to content

Fix replacer error on patches with empty Runs#2875

Merged
dolanmiu merged 7 commits intodolanmiu:masterfrom
SebKranz:fix_empty_text_runs
Dec 3, 2024
Merged

Fix replacer error on patches with empty Runs#2875
dolanmiu merged 7 commits intodolanmiu:masterfrom
SebKranz:fix_empty_text_runs

Conversation

@SebKranz
Copy link
Contributor

@SebKranz SebKranz commented Dec 2, 2024

This PR fixes the error in #2855, which occurs because of two minor issues:

  1. TextRun("") and TextRun({ text: "" }) counterintuitively didn't do the same thing. One creates an inner Text and one doesn't. This PR changes TextRun(""), so that both always create the inner Text.
  2. replacer didn't handle patches with empty Runs. This is also fixed by this PR.

Since `Run` already has a option for instantiating a `Text` element, we don't need to push children here.
describe("replacer", () => {
describe("replacer", () => {
it("should throw an error if nothing is added", () => {
it("should return { didFindOccurrence: false } if nothing is added", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot to change the description in PR #2856.

@SebKranz SebKranz force-pushed the fix_empty_text_runs branch from ff0f43e to 13fee3a Compare December 2, 2024 17:21
@dolanmiu dolanmiu self-requested a review December 2, 2024 23:58
@codecov
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (64505a2) to head (13fee3a).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2875   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          286       286           
  Lines        14366     14359    -7     
  Branches      1400      1400           
=========================================
- Hits         14366     14359    -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dolanmiu
Copy link
Owner

dolanmiu commented Dec 3, 2024

Thank you!

@dolanmiu dolanmiu merged commit b89b571 into dolanmiu:master Dec 3, 2024
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