-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
Ensure TextInfo.getTextInChunks does not freeze, and provide new friendly compareable TextInfo endpoint properties #12253
Conversation
…l comparisons with start and end properties of other TextInfo instances, For example: a.start <= b.end This way should now be preferred over calling compareEndPoints directly. and these start and end properties can also be set using other start and end properties For example: a.start = a.end This way should be preferred over calling setEndPoint directly.
See test results for failed build of commit 541d42907d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, way more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
This change should belong to "Changes for developers" but it appears in "Bug Fixes". |
Link to issue number:
Fixes #11613
Summary of the issue:
TextInfo.getTextInChunks could sometimes end up in an infinit loop when dealing with particular TextInfo implementations such as ITextDocument where setting start to the end of the document results in the start never quite getting there.
Description of how this pull request fixes the issue:
To work around this specific freeze, getTextInChunks now double checks that the start has really moved to the end of the last chunk. If not, we break out of the loop.
However, for a long time now we have wanted to make these TextInfo comparsons much more readable, which can aide in finding logic errors much easier.
To that end, TextInfo objects now have start and end properties, which can be compared mathematically, and also set from another, removing the need to use compareEndPoints or setEndPoint.
Some examples:
Setting a's end to b's start
Original code:
New code:
Is a's start at or past b's end?
Original code:
New code:
TextInfo.getTextInChunks has been rewritten to use these new properties.
Testing strategy:
Known issues with pull request:
None.
Change log entry:
Changes for developers:
< <= == != >= >
and also can be set from each other. Thus it is now preferred to write code such asa.start <= b.end
rather thana.compareEndPoints(b, "startToEnd") <= 0
. Anda.start = b.end
rather thana.setEndPoint(b, "startToend")
.Code Review Checklist:
This checklist is a reminder of things commonly forgotten in a new PR.
Authors, please do a self-review and confirm you have considered the following items.
Mark items you have considered by checking them.
You can do this when editing the Pull request description with an x:
[ ]
becomes[x]
.You can also check the checkboxes after the PR is created.