Fix overly-aggressive unhangRange #5193
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.
Description
Editor.unhangRange()
could decide to proceed with an adjustment in cases where the range was not hanging. Because the algorithm it uses always skips over the first node it encounters, this meant the selection was adjusted in non-hanging cases. This change reduces the chances of an incorrect decision to adjust. Transforms now pass thevoids
flag tounhangRange()
as it seems logical that the adjusted range should reflect the intention of the operation.This change fixes a unit test I added for markable voids that had to be skipped because of the
unhangRange()
error, and fixes a couple other long-skipped tests.Example
Previous code behavior in the Mentions example when the range is not hanging and the word "Test" is typed:
Because the range gets adjusted even though it is not hanging, the inline element at the end of the line remains.
New code behavior in the same scenario:
Context
The
unhangRange
logic error mostly centers around testing foroffset === 0
in theend
of the range. This meant that if the end of the selection is in or after an inline void element the adjustment would be triggered incorrectly because of the empty Texts associated and adjacent to those.Checks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)yarn changeset add
.)