Fix issue that paste will remove cache #2900
Merged
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.
I found that when paste, we will always use cloned model as target model, although the model content is the same, but it will clear all caches so that after paste we need to rerender the whole content.
It is because of a code bug that we always assign
modelBeforePaste
to clipboardData even for the first paste, so when we merge paste model, it is always treated as second paste.To fix it, add a parameter to tell
mergePasteContent
API that it is a first paste although there ismodelBeforePaste
in clipboardData. Then we will not clone model again, so caches can be preserved.