File tree Expand file tree Collapse file tree
Sources/Textual/Internal/TextFragment
Tests/TextualTests/Internal/TextFragment Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ extension Text {
9797 }
9898
9999 self = textValues. reduce ( Text ( verbatim: " " ) ) { partialResult, text in
100- Text ( " \( partialResult) \( text) " )
100+ partialResult + text
101101 }
102102 }
103103
Original file line number Diff line number Diff line change 1+ #if os(macOS)
2+ import SwiftUI
3+ import Testing
4+
5+ @testable import Textual
6+
7+ @MainActor
8+ struct TextBuilderTests {
9+ @Test func renderingManyAttributedRunsDoesNotOverflowStack( ) {
10+ let renderer = ImageRenderer (
11+ content: TextFragment ( Self . attributedStringWithManyRuns ( count: 2_500 ) )
12+ . frame ( width: 320 )
13+ . fixedSize ( horizontal: false , vertical: true )
14+ . coordinateSpace ( . textContainer)
15+ )
16+ renderer. proposedSize = . init( width: 320 , height: 4_000 )
17+
18+ #expect( renderer. nsImage != nil )
19+ }
20+
21+ private static func attributedStringWithManyRuns( count: Int ) -> AttributedString {
22+ ( 0 ..< count) . reduce ( into: AttributedString ( ) ) { result, index in
23+ var fragment = AttributedString ( index. isMultiple ( of: 40 ) ? " \n " : " x " )
24+ fragment. font = index. isMultiple ( of: 2 ) ? . body. bold ( ) : . body
25+ result += fragment
26+ }
27+ }
28+ }
29+ #endif
You can’t perform that action at this time.
0 commit comments