<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
Hi Nicolas.<div><br></div><div>> <span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Beware, Text depends on this feature of accessing runs out of bounds, because the characterIndex might be past end.</span><br><div><br></div><div>Good catch!</div></div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div>
<blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
<p style="color: #AAAAAA; margin-top: 10px;">Am 29.12.2019 17:32:26 schrieb commits@source.squeak.org <commits@source.squeak.org>:</p><div style="font-family:Arial,Helvetica,sans-serif">Nicolas Cellier uploaded a new version of Collections to project The Trunk:<br>http://source.squeak.org/trunk/Collections-nice.868.mcz<br><br>==================== Summary ====================<br><br>Name: Collections-nice.868<br>Author: nice<br>Time: 28 December 2019, 1:23:35.502843 pm<br>UUID: e4026d16-31b5-430f-8c22-6475db37bb91<br>Ancestors: Collections-mt.866<br><br>Fix RunArrayTest>>testAt2 (testing access out of bounds)<br><br>Beware, Text depends on this feature of accessing runs out of bounds, because the characterIndex might be past end.<br><br>To avoid problems, transform previous #at: implementation into #atPin: and use that in Text.<br>#atPin: clamps the index in accessible range.<br><br>=============== Diff against Collections-mt.866 ===============<br><br>Item was changed:<br> ----- Method: RunArray>>at: (in category 'accessing') -----<br> at: index<br> <br>+ self at: index setRunOffsetAndValue: [:run :offset :value | <br>+ offset < 0="" iftrue:="" [="" self="" errorsubscriptbounds:="" index=""><br>+ offset >= (runs at: run) ifTrue: [ self errorSubscriptBounds: index ].<br>+ ^value]!<br>- self at: index setRunOffsetAndValue: [:run :offset :value | ^value]!<br><br>Item was added:<br>+ ----- Method: RunArray>>atPin: (in category 'accessing') -----<br>+ atPin: index<br>+ <br>+ self at: index setRunOffsetAndValue: [:run :offset :value | ^value]!<br><br>Item was changed:<br> ----- Method: Text>>alignmentAt:ifAbsent: (in category 'emphasis') -----<br> alignmentAt: characterIndex ifAbsent: aBlock<br> | attributes emph |<br> self size = 0 ifTrue: [^aBlock value].<br> emph := nil.<br>+ attributes := runs atPin: characterIndex.<br>- attributes := runs at: characterIndex.<br> attributes do:[:att | (att isKindOf: TextAlignment) ifTrue:[emph := att]].<br> emph ifNil: [ ^aBlock value ].<br> ^emph alignment!<br><br>Item was changed:<br> ----- Method: Text>>attributesAt: (in category 'emphasis') -----<br> attributesAt: characterIndex <br> "Answer the code for characters in the run beginning at characterIndex."<br> "NB: no senders any more (supplanted by #attributesAt:forStyle: but retained for the moment in order not to break user code that may exist somewhere that still calls this"<br> | attributes |<br> self size = 0<br> ifTrue: [^ Array with: (TextFontChange new fontNumber: 1)]. "null text tolerates access"<br>+ attributes := runs atPin: characterIndex.<br>- attributes := runs at: characterIndex.<br> ^ attributes!<br><br>Item was changed:<br> ----- Method: Text>>attributesAt:do: (in category 'emphasis') -----<br> attributesAt: characterIndex do: aBlock<br> "Answer the code for characters in the run beginning at characterIndex."<br> "NB: no senders any more (supplanted by #attributesAt:forStyle: but retained for the moment in order not to break user code that may exist somewhere that still calls this"<br> self size = 0 ifTrue:[^self].<br>+ (runs atPin: characterIndex) do: aBlock!<br>- (runs at: characterIndex) do: aBlock!<br><br>Item was changed:<br> ----- Method: Text>>attributesAt:forStyle: (in category 'emphasis') -----<br> attributesAt: characterIndex forStyle: aTextStyle<br> "Answer the code for characters in the run beginning at characterIndex."<br> | attributes |<br> self size = 0<br> ifTrue: [^ Array with: (TextFontChange new fontNumber: aTextStyle defaultFontIndex)]. "null text tolerates access"<br>+ attributes := runs atPin: characterIndex.<br>- attributes := runs at: characterIndex.<br> ^ attributes!<br><br>Item was changed:<br> ----- Method: Text>>colorAt:ifNone: (in category 'emphasis') -----<br> colorAt: characterIndex ifNone: block<br> <br> self size = 0 ifTrue: [^ block value]. "null text tolerates access."<br> <br>+ ^ (runs atPin: characterIndex)<br>- ^ (runs at: characterIndex)<br> detect: [:attr | attr class == TextColor]<br> ifFound: [:attr | attr color]<br> ifNone: block!<br><br>Item was changed:<br> ----- Method: Text>>emphasisAt: (in category 'emphasis') -----<br> emphasisAt: characterIndex<br> "Answer the fontfor characters in the run beginning at characterIndex."<br> | attributes |<br> self size = 0 ifTrue: [^ 0]. "null text tolerates access"<br>+ attributes := runs atPin: characterIndex.<br>- attributes := runs at: characterIndex.<br> ^attributes inject: 0 into: <br> [:emph :att | emph bitOr: att emphasisCode].<br> !<br><br>Item was changed:<br> ----- Method: Text>>fontAt:withStyle: (in category 'emphasis') -----<br> fontAt: characterIndex withStyle: aTextStyle<br> "Answer the fontfor characters in the run beginning at characterIndex."<br> | attributes font |<br> self size = 0 ifTrue: [^ aTextStyle defaultFont]. "null text tolerates access"<br>+ attributes := runs atPin: characterIndex.<br>- attributes := runs at: characterIndex.<br> font := aTextStyle defaultFont. "default"<br> attributes do: <br> [:att | att forFontInStyle: aTextStyle do: [:f | font := f]].<br> ^ font!<br><br>Item was changed:<br> ----- Method: Text>>fontNumberAt: (in category 'emphasis') -----<br> fontNumberAt: characterIndex <br> "Answer the fontNumber for characters in the run beginning at characterIndex."<br> | attributes fontNumber |<br> self size = 0 ifTrue: [^1]. "null text tolerates access"<br>+ attributes := runs atPin: characterIndex.<br>- attributes := runs at: characterIndex.<br> fontNumber := 1.<br> attributes do: [:att | (att isMemberOf: TextFontChange) ifTrue: [fontNumber := att fontNumber]].<br> ^ fontNumber<br> !<br><br><br></div></blockquote></div>