Fix tab replacement composition crash #5066
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.
Composition on the entire node was hitting the "reuse" this same node part to render the new content (
firstNode.spliceText(startOffset, delCount, text, true);
). While it's a very optimal path that doesn't recreate the node and works well with composition tab node content should always strictly be\n
. This PR forces it to recreate a new node, just like we do with token node, segmented, or other formatting edge cases.This PR isn't ideal, the solution comes down to finding a generic solution for this issue: #5065
Chrome:
Works fairly well except that the cursor is not updated but it's a nit and doesn't affect functionality (the same functionality resembles if you select a range that includes plain text and bold)
Screen.Recording.2023-09-28.at.4.47.20.PM.mov
Firefox and Safari:
Adds an additional space in the beginning, likely because of different DOM nodes and some browser magic.
Screen.Recording.2023-09-28.at.4.48.48.PM.mov