[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 06:32:28 UTC 2018

On Thursday 05 July 2018 05:30 AM, David T. Lewis wrote:
> Indeed, a text with runs that refer to positions beyond the end of
> the string does not seem right. Possibly a bug in text editing that
> permits this condition to occur?
I think Bob's right. In fact, the cs need not even be filed in. Just 
browsing it in ChangeList is sufficient to trigger the error.
The text ivar produced by the scanner has the wrong runs.

> Meanwhile, I was looking at your tip about the runStopIndex being 71
> for the funky styled text and 70 otherwise. Attached is an update to
> CharacterBlockScanner>>characterBlockAtPoint:index:in: that prevents
> the out of range condition and fixes the FooClient class comment display.

It is the runs array that is incorrect in the text. Should we assert 
runs size <= aString size in:

Text>>#setString: aString setRunsChecking: aRunArray
	"Check runs and do the best you can to make them fit..."

	string := aString.
	"check the runs"
	aRunArray ifNil: [^ aString asText].
	(aRunArray isKindOf: RunArray) ifFalse: [^ aString asText].
	aRunArray runs size = aRunArray values size ifFalse: [^ aString asText].
	aRunArray size = aString size ifFalse: [^ aString asText].
	runs := aRunArray

Regards .. Subbu

More information about the Squeak-dev mailing list