Skip to content

Fix TextBuilder stack overflow with many attributed runs#65

Merged
gonzalezreal merged 1 commit into
gonzalezreal:mainfrom
markawilliamson:fix/textbuilder-stack-overflow
Jun 14, 2026
Merged

Fix TextBuilder stack overflow with many attributed runs#65
gonzalezreal merged 1 commit into
gonzalezreal:mainfrom
markawilliamson:fix/textbuilder-stack-overflow

Conversation

@markawilliamson

Copy link
Copy Markdown
Contributor

Summary

  • Concatenate Text fragments with partialResult + text instead of localized interpolation
  • Add a macOS regression test that renders 2,500 attributed runs and forces SwiftUI text resolution

This avoids building a recursively nested LocalizedStringKey/Text interpolation tree when TextBuilder combines many attributed runs.

Fixes #64.

Testing

  • swift test --filter TextBuilderTests
  • swift test --skip CodeTokenizerTests

I also ran unfiltered swift test; it built successfully but my local run failed in the existing CodeTokenizerTests because the tokenizer was nil, unrelated to this change.

@gonzalezreal

Copy link
Copy Markdown
Owner

Hi @markawilliamson,

Thanks for the fix and the regression test! ❤️
CI failures are unrelated to this PR and already fixed in main.

@gonzalezreal gonzalezreal merged commit b38f46e into gonzalezreal:main Jun 14, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stack overflow resolving SwiftUI Text for many attributed runs

2 participants