Marcel Taeumel uploaded a new version of Collections to project The Trunk: http://source.squeak.org/trunk/Collections-mt.1050.mcz
==================== Summary ====================
Name: Collections-mt.1050 Author: mt Time: 14 September 2023, 4:59:12.295231 pm UUID: e3a36b63-6434-b140-bf66-44d075d72970 Ancestors: Collections-mt.1049
In texts, invalid intervals for add/remove text attributes violated the contract that the size of a text's runs equals that text's content/string size. Fix that by clamping those intervals to the content size.
I wonder if #copyFrom:to: and #copyReplaceFrom:to:with: need a similar protection... Nicolas? Levente? :-)
=============== Diff against Collections-mt.1049 ===============
Item was changed: ----- Method: Text>>addAttribute:from:to: (in category 'emphasis') ----- addAttribute: att from: start to: stop "Set the attribute for characters in the interval start to stop." + + | stringSize realStart realStop | + (stringSize := self size) = 0 ifTrue: [^ self]. + start < 1 + ifTrue: [realStart := 1] + ifFalse: [realStart := start min: stringSize]. + stop > self size + ifTrue: [realStop := stringSize] + ifFalse: [realStop := stop max: realStart]. + runs := runs copyReplaceFrom: realStart to: realStop + with: ((runs copyFrom: realStart to: realStop) - runs := runs copyReplaceFrom: start to: stop - with: ((runs copyFrom: start to: stop) replace: [:attributes | Text addAttribute: att toArray: attributes]) !
Item was changed: ----- Method: Text>>removeAttribute:from:to: (in category 'emphasis') ----- removeAttribute: att from: start to: stop "Remove the attribute over the interval start to stop." + + | stringSize realStart realStop | + (stringSize := self size) = 0 ifTrue: [^ self]. + start < 1 + ifTrue: [realStart := 1] + ifFalse: [realStart := start min: stringSize]. + stop > self size + ifTrue: [realStop := stringSize] + ifFalse: [realStop := stop max: realStart]. + runs := runs copyReplaceFrom: realStart to: realStop + with: ((runs copyFrom: realStart to: realStop) - runs := runs copyReplaceFrom: start to: stop - with: ((runs copyFrom: start to: stop) replace: [:attributes | attributes copyWithout: att]) !
packages@lists.squeakfoundation.org