Skip to content

Fix RebuildBuffer block segment newline bug#224

Merged
Aaronontheweb merged 1 commit into
devfrom
fix/rebuildbuffer-race
May 24, 2026
Merged

Fix RebuildBuffer block segment newline bug#224
Aaronontheweb merged 1 commit into
devfrom
fix/rebuildbuffer-race

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Owner

Problem

RebuildBuffer() clears the buffer then calls EnsureBlockNewLine() to check if a block segment needs a preceding newline. But since the buffer was just cleared, HasContentOnCurrentLine returns false and no newline gets inserted — so both 'Static line' and the spinner end up on the same buffer line, causing GetAllStyledLines()[1] to crash.

Fix

Moved the block-segment newline check inline in RebuildBuffer() and check buffer state after the previous element has been appended, not before.

RebuildBuffer() cleared the buffer then called EnsureBlockNewLine()
which checked _buffer.HasContentOnCurrentLine. Since the buffer was
just cleared, this returned false and no newline was inserted before
block segments, causing both 'Static line' and the spinner to end up
on the same buffer line. The test then crashed reading index [1].

Fix: moved the block-segment newline check inline, checking buffer
state after the previous element has been appended rather than before.
@Aaronontheweb Aaronontheweb marked this pull request as ready for review May 24, 2026 18:01
@Aaronontheweb Aaronontheweb merged commit e0777c1 into dev May 24, 2026
13 checks passed
@Aaronontheweb Aaronontheweb deleted the fix/rebuildbuffer-race branch May 24, 2026 18:01
Aaronontheweb added a commit that referenced this pull request May 24, 2026
- Update VersionPrefix to 0.10.1
- Refresh PackageReleaseNotes with the StreamingTextNode thread-safety
  fixes (PRs #224, #225, #226, #227)
- Prepend 0.10.1 section to RELEASE_NOTES.md
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.

1 participant