Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Merges aren't preserved when cells containing merges get overwritten after row inserts. Instead, the value of a merged cell gets applied to all cells in the merge separately.
becomes
This is because the values for the previously merged cells are pulled from the source row (
rSrc.values
inspliceRows
). The source row's values repeat the merged value for each cell in the merge. For example, the source row values for the row in the first table would be["merged cell text", "merged cell text"]
. These values are what gets applied to the cells in the destination row (rDst
), and the merge is lost.The extra lines I wrote in
spliceRows
to fix this reapply merges to cells while accounting for the offset caused by a row insert.Test plan
I added a test to spec/unit/doc/worksheet.merge.spec for this issue and verified that it passes with the changes I made.