Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#853@minor: Fix method Range.cloneContents #854

Merged

Conversation

danielrentz
Copy link
Contributor

@danielrentz danielrentz commented Apr 13, 2023

fix #853

Seems the method initializes the initial subrange (the first element containing the start of the selection) incorrectly (Range.ts, line 282):

  • Currently, the subrange will be created from end of current range to end of firstPartialContainedChild.
  • Obviously, the subrange should clone from start of original range to end of firstPartialContainedChild.

Seems that existing unit test did not catch this because selection does not start inside a sub element.

Minor additional fix: I removed the else-if branches in the startOffset and endOffset getters. Code would only run into the else-if branch if the offset property is already 0 (otherwise the initial if-branch would trigger and reset the offset property to 0). Therefore the else-if branch does not have any effect.

Copy link
Owner

@capricorn86 capricorn86 left a comment

Choose a reason for hiding this comment

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

NIce find! 🌟

@capricorn86 capricorn86 merged commit e697ebc into capricorn86:master Apr 13, 2023
1 check passed
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.

Method Range.cloneContents: endless loop
2 participants