[squeak-dev] [5.2a] styled text in a class comment spawns endless subscript out-of-bounds

K K Subbu kksubbu.ml at gmail.com
Thu Jul 5 09:21:58 UTC 2018


On Wednesday 04 July 2018 09:23 PM, David T. Lewis wrote:
> A clue that this might be accumulation of kludges: Looking at senders of
> selectInvisiblyFrom:to: (such as TextEditor>>addText:event:) shows a number
> of methods that subtract 1 from the stop index when before calling the method
> that adds 1 back to the stop index. This certainly does not have a good smell.
Looks like different intervals for dealing with selections and 
substrings. I see that the names used are start/stop instead of 
startIndex/stopIndex. I found this consistent pattern in all methods 
that deal with selections.

   stop = (stopIndex - 1)
   stopIndex = (stop + 1)

Regular methods that deal with substrings like 
AbstractFont>>#widthOString... and BitBlt>>#primDisplayString... and the 
scanner methods iterate over aString with:

    startIndex to: stopIndex

while Editor>>selectionInterval extracts selections with startIndex to: 
(stopIndex-1).

Regards .. Subbu


More information about the Squeak-dev mailing list