mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 04:55:58 +03:00
[PR #688] [MERGED] fix(buffer): prevent WrongGeneration panic when set() replaces grapheme with same ID #1493
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#1493
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/anomalyco/opentui/pull/688
Author: @remorses
Created: 2/14/2026
Status: ✅ Merged
Merged: 2/15/2026
Merged by: @simonklee
Base:
main← Head:fix/grapheme-pool-wrong-generation📝 Commits (4)
5e57b93fix(buffer): prevent WrongGeneration panic when set() replaces grapheme with same IDb4df742fix(buffer): use counted grapheme tracking to prevent WrongGeneration panicscae1a9fMerge remote-tracking branch 'origin/main' into fix/grapheme-pool-wrong-generation167cb38prettier:write📊 Changes
6 files changed (+249 additions, -113 deletions)
View changed files
📝
packages/core/src/buffer.test.ts(+35 -0)📝
packages/core/src/zig/buffer.zig(+14 -3)📝
packages/core/src/zig/grapheme.zig(+34 -6)📝
packages/core/src/zig/tests/buffer_test.zig(+110 -0)📝
packages/core/src/zig/tests/grapheme_test.zig(+6 -0)📝
packages/solid/tests/scrollbox-cleanchildren.test.tsx(+50 -104)📄 Description
Fixes the GraphemePool WrongGeneration panic that crashes termcast e2e tests.
Root cause:
OptimizedBuffer.set()removes the old grapheme from the tracker (decref to 0 → slot freed) before adding the new one. When old and new cells share the same grapheme ID but different packed char values (different extent bits), the slot goes to the free list between remove and add. Any interveningpool.alloc()can reuse it, bumping the generation counter, causingWrongGenerationon the subsequent incref.Fix: when the new cell uses the same grapheme ID as the old one, pre-add it to the tracker before removing the old entry. This keeps refcount >= 1, preventing the slot from reaching the free list.
Adds Zig + TypeScript regression tests exercising grapheme pool churn across render frames with dialog open/close cycles.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.