Conversation
When a nested list item was followed by a blank line and then a paragraph at column 0, the outer `InList` handler was folding that paragraph into the outer item as a lazy continuation instead of terminating the list. The root cause was two-fold. First, `flush_list_segment` drained the exact bytes it emitted into the Block, which consumed the trailing blank line that carried the `prev_blank=true` termination signal. The parent state therefore never saw the blank and treated the following content as a continuation. Second, `prev_blank` was always initialised to `false` at the start of `handle_in_list`, even when a leading blank had already been stripped from the buffer head — so a child scope that consumed the blank during its own flush left the parent unaware. The fix splits `flush_list_segment`'s single `flush_pos` parameter into two: `content_end` (how many bytes go into the Block) and `drain_end` (how many bytes are removed from the buffer). For the `Terminator` branch, `content_end = scan` (includes trailing blanks, so the renderer preserves the visual separator) while `drain_end = last_content_end` (stops before the blanks, leaving them in the buffer for the popped-to parent state to pick up as `prev_blank=true`). For `SiblingMarker` and `NestedContainer` branches the two values are identical, preserving existing behaviour. `prev_blank` is now seeded from `leading_blank > 0` so re-entry after a child scope consumed a blank fires the terminator check on the very first line. Signed-off-by: Jean Mertz <git@jeanmertz.com>
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.
When a nested list item was followed by a blank line and then a paragraph at column 0, the outer
InListhandler was folding that paragraph into the outer item as a lazy continuation instead of terminating the list.The root cause was two-fold. First,
flush_list_segmentdrained the exact bytes it emitted into the Block, which consumed the trailing blank line that carried theprev_blank=truetermination signal. The parent state therefore never saw the blank and treated the following content as a continuation. Second,prev_blankwas always initialised tofalseat the start ofhandle_in_list, even when a leading blank had already been stripped from the buffer head — so a child scope that consumed the blank during its own flush left the parent unaware.The fix splits
flush_list_segment's singleflush_posparameter into two:content_end(how many bytes go into the Block) anddrain_end(how many bytes are removed from the buffer). For theTerminatorbranch,content_end = scan(includes trailing blanks, so the renderer preserves the visual separator) whiledrain_end = last_content_end(stops before the blanks, leaving them in the buffer for the popped-to parent state to pick up asprev_blank=true). ForSiblingMarkerandNestedContainerbranches the two values are identical, preserving existing behaviour.prev_blankis now seeded fromleading_blank > 0so re-entry after a child scope consumed a blank fires the terminator check on the very first line.