Comment #6 on issue 2704 by elpochod...@gmail.com: Tests for broken withNoLineLongerThan: behavior. http://code.google.com/p/pharo/issues/detail?id=2704 I have another implementation for this method, which I think may be a bit cleaner (and also passes all tests) withNoLineLongerThan: maxWidth "Answer a string with the same content as receiver, but rewrapped so that no line has more characters than the given number" | res size left right limit next | size := self size. maxWidth isNumber not | (maxWidth < 1) ifTrue: [self error: 'too narrow']. ^self class new: size * (maxWidth + 1) // maxWidth "provision for supplementary line breaks" streamContents: [ :stream | right := 1. [right <= size] whileTrue: [ left := self indexOfAnyOf: CSNonSeparators startingAt: right ifAbsent: [ ^stream next: size - left + 1 putAll: self startingAt: left; contents ]. limit := left + maxWidth - 1. (limit >= size) ifTrue: [ ^stream next: size - left + 1 putAll: self startingAt: left; contents ]. next := left. [ next - 1 <= limit ] whileTrue: [ right := next. next := self indexOfAnyOf: CSSeparators startingAt: next + 1 ifAbsent: [ (next = left) ifTrue: [ limit + 1] ifFalse: [ limit+2 ] ]. (CSLineEnders includes: (self at: right)) ifTrue: [ next := limit+2]. ]. stream next: right - left putAll: self startingAt: left. (right <= size) ifTrue: [ stream cr ]. ] ].