nvda
0efeee4b - Ensure TextInfo.getTextInChunks does not freeze, and provide new friendly compareable TextInfo endpoint properties (#12253)

Commit
4 years ago
Ensure TextInfo.getTextInChunks does not freeze, and provide new friendly compareable TextInfo endpoint properties (#12253) 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. 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 comparisons 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: a.setEndPoint(b, "endToStart") New code: a.end = b.start Is a's start at or past b's end? Original code: a.compareEndPoints(b, "startToEnd") >= 0 New code: a.start >= b.end TextInfo.getTextInChunks has been rewritten to use these new properties.
Parents
Loading