[squeak-dev] Text Style Code in TextMorph

Rein, Patrick Patrick.Rein at hpi.de
Wed Jul 20 15:49:52 UTC 2016

Hi everyone,

I have just started investigating a bug with the PluggableTextMorphPlus where a TextStyle affecting a complete Text remained valid after setting a String instead. During debugging I have encountered the following code in TextMorph>>#newContents:

(text notNil and: [ (textSize := text size) > 0] and: [ (text runLengthFor: 1) = textSize ])
    ifTrue: [ | attribs |
attribs := text attributesAt: 1 forStyle: textStyle.
Text string: stringOrText copy attributes: attribs.]
    ifFalse: [ Text fromString: stringOrText copy ]

What it does is that if the previous style applied to all of the Text, then the new Text also gets this style applied. Why is that? That seems pretty weird to me to only handle this one special case. Does anyone know the rational behind that?

Thanks and bests

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160720/f7210c5b/attachment.htm

More information about the Squeak-dev mailing list