Skip to content

Fix EventHint merge bug - #763

Merged
zxch3n merged 5 commits into
mainfrom
fix-local-event
Aug 5, 2025
Merged

Fix EventHint merge bug#763
zxch3n merged 5 commits into
mainfrom
fix-local-event

Conversation

@zxch3n

@zxch3n zxch3n commented Aug 5, 2025

Copy link
Copy Markdown
Member

Fix EventHint cross-container merge bug

Problem

When multiple containers are modified in the same transaction, their EventHints could be incorrectly merged together. This caused events to be lost or attributed to the wrong container

For example:

text_a.delete(0, 1); // Delete from text_a
text_b.delete(0, 1); // Delete from text_b
doc.commit();

Would generate only 1 event instead of 2, with both operations incorrectly attributed to 'text_a'

Solution

Added container ID tracking to EventHints to prevent cross-container merging:

  • Created 'EventHintWithContainer' wrapper that includes the container index
  • Updated merge logic to only merge hints from the same container
  • Modified 'change_to_diff' to handle the new wrapper type

zxch3n and others added 4 commits August 5, 2025 16:00
Add test cases that demonstrate the bug where EventHints from different
containers are incorrectly merged when they have compatible positions.

The minimal test shows that when deleting from two text containers in
the same transaction, only one event is generated instead of two, with
the operations incorrectly attributed to a single container.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add container index tracking to EventHints to ensure hints from different
containers are never merged. This fixes the issue where operations on
different text containers in the same transaction would be incorrectly
merged, causing events to be lost or misattributed.

The fix wraps EventHint in EventHintWithContainer which includes the
container index, and updates the merge logic to check container indices
match before allowing merges.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

WASM Size Report

  • Original size: 3062.95 KB
  • Gzipped size: 971.10 KB
  • Brotli size: 675.40 KB

@zxch3n zxch3n changed the title Fix local event Fix EventHint causing merge bug Aug 5, 2025
@zxch3n zxch3n changed the title Fix EventHint causing merge bug Fix EventHint merge bug Aug 5, 2025
@zxch3n
zxch3n merged commit f8bef58 into main Aug 5, 2025
1 check passed
@zxch3n
zxch3n deleted the fix-local-event branch August 5, 2025 17:30
@Leeeon233 Leeeon233 mentioned this pull request Aug 5, 2025
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