Proposal: Rename Range.includes
to Range.intersects
and add Range.surrounds
to remove confusion
#4283
Labels
Range.includes
to Range.intersects
and add Range.surrounds
to remove confusion
#4283
Problem
Jason Tamulonis expressed that to him
includes
means that one Range fully includes another in Slack.Andrew Herron added
My intuition is similar. The issue can be addressed by renaming the method for clarity and adding another method to handle the use case of what others were looking for.
Solution
Rename
Range.includes
toRange.intersects
. This adds clarity as the language suggests that if any part of one range is in any part of the other, it shall return true, which is the behavior.Add a method
Range.surrounds
which addresses the desired functionality of detecting that one range completely surrounds (or is equal to) the entire other range.Alternatives
Improving the documentation is one step towards reducing confusion, which I will also do. I'll just add it since that's an easy win. Note: DONE https://docs.slatejs.org/api/locations/range#range-includes-range-range-target-path-or-point-or-range-boolean
Context
As this is a breaking change, @ianstormtaylor
Thumbs up to approve, Thumbs down to disapprove proposal
The text was updated successfully, but these errors were encountered: