Repository navigation
Conversation
InlineText, StructuredText, WithInlineStyle and TextFragment wrote their derived values into @State from onChange(of:initial:), so their first layout pass used an empty attributed string or an empty Text. A List sizes rows before that state settles, and the rows change height after the list measures them. Derive these values in body and keep the last one in a small Memo, so the first pass lays out the final text and the work only repeats when its input changes.
BlockVStack applied block spacing from a preference through onPreferenceChange, so every block laid out without its spacing first, and a List measured StructuredText rows at that height. textual.blockSpacing(_:) now also sets a container value, which the stack reads in the same pass. Stacks pass the spacing of their blocks on, so lists and block quotes keep taking the spacing of the blocks inside them. The preference stays as the final value, which covers styles that set the spacing on a view inside a container. The GitHub heading style sets its spacing on its root view, so it lays out with it on the first pass too.
y-a-v-a
added a commit
to y-a-v-a/textual
that referenced
this pull request
Oct 22, 2026
StructuredText, InlineText, WithInlineStyle and TextFragment seeded their content from onChange(initial:), so every view first laid out empty. A List or a UIHostingConfiguration cell measures a row on that pass, and the row then changes height under it; a view that a lazy container materializes can miss the event altogether and stay blank. Each of them now derives its content in body through a Memo, as gonzalezreal#84 and gonzalezreal#90 propose. Adapted to the fork's streaming throttle: the markup is parsed in body only until the first change has been parsed, and later changes still go through the throttle, parsing inside the throttled operation so that the window keeps excluding the parse. The TextBuilder is keyed on the text environment as well as the content (gonzalezreal#84), and starts from the last container size, since the container may not resize again to report it when only the environment changes. In the renderer benchmarks this halves the TextBuilders a document builds once its content lands, and initial render with selection enabled is faster. Co-authored-by: Paul Schmiedmayer <PSchmiedmayer@users.noreply.github.com> Co-authored-by: Shai Mishali <shai@riverside.fm> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y7W6e4M3bCGaGpJzVY8c39
y-a-v-a
pushed a commit
to y-a-v-a/textual
that referenced
this pull request
Oct 22, 2026
BlockVStack applied block spacing from a preference through onPreferenceChange, so every block laid out without its spacing first, and a List measured StructuredText rows at that height. textual.blockSpacing(_:) now also sets a container value, which the stack reads in the same pass. Stacks pass the spacing of their blocks on, so lists and block quotes keep taking the spacing of the blocks inside them. The preference stays as the final value, which covers styles that set the spacing on a view inside a container. The GitHub heading style sets its spacing on its root view, so it lays out with it on the first pass too. (cherry picked from commit e7e269f, gonzalezreal#90) Adapted to the fork: list items wrap the task-list-aware content in the subviews group, so a task item's checkbox and its spacing come through together, and the block layout view keeps deriving its spacing in body so list item spacing still follows environment changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y7W6e4M3bCGaGpJzVY8c39
y-a-v-a
pushed a commit
to y-a-v-a/textual
that referenced
this pull request
Oct 22, 2026
(cherry picked from commit 435516b, gonzalezreal#90)
y-a-v-a
added a commit
to y-a-v-a/textual
that referenced
this pull request
Oct 22, 2026
Upstream main has had no new commits since 0.5.0 (2026-06-15), which the fork already contains. The activity since then is in open pull requests; the fixes among them are merged here, cherry-picked with their authorship and adapted where they overlap with the fork: - gonzalezreal#67, gonzalezreal#70, gonzalezreal#71, gonzalezreal#80: selection faults and crashes - gonzalezreal#92: TextBuilder stack overflow on iOS - gonzalezreal#83: caller attributes kept on code blocks - gonzalezreal#86: stale content after markup changes, keeping loaded attachments while streamed content resolves - gonzalezreal#91: attachment accessibility labels - gonzalezreal#84, gonzalezreal#90: content on the first layout pass, so List rows keep their height and ImageRenderer draws text Also fixes a fork bug the gonzalezreal#80 tests exposed (the selection model ignored a change to an empty layout collection) and two timing-dependent tests. Feature pull requests (gonzalezreal#69, gonzalezreal#78, gonzalezreal#79, gonzalezreal#81, gonzalezreal#82, gonzalezreal#88) are left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y7W6e4M3bCGaGpJzVY8c39
Tlaster
added a commit
to Tlaster/textual
that referenced
this pull request
Nov 28, 2026
Derive parsed markup, inline styles and text builders during the initial layout. Read block margins through native container values on supported systems and retain preference-based spacing for older deployment targets. Port of gonzalezreal#90, commits 3e80a2f and e7e269f. Co-authored-by: Shai Mishali <shai@riverside.fm>
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey @gonzalezreal 👋 been a while since my last PR :)
Prefacing with the fact this PR only looks large because like 50-60% of it is a snapshot test to validate, fix itself is rather small :)
I'm implementing a
Listwhere each item has aStructuredTextin it and noticed an interesting bug. Even with static amount of items, the content jumps around heavily which immediately hinted me towards a sizing / calc issue.After digging it seems like there is more than one sizing pass per StructuredText, due to the lazy nature of List. The view starts off with an empty string initially which causes the initial wrongful calculation, after which
onChange(of:initial:)fires with the right value slightly later, which is what causes this drift:list-row-sizing-comparison.mp4
This PR adds a tiny
Memotype that keeps the last input and result, which guarantees thebodyhas the proper value to calculate from, and only does that calculation once (per input). Block spacing had the same problem (it came from onPreferenceChange), so it’s now read in the same pass too, keeping things aligned and stable.Would really apprecaite your thoughts :) thanks!
Fixes #52 - which seems to be the same issue.