Skip to content

fix(canvas): seed an empty paragraph when pouring text into a fresh cell#3

Merged
drietsch merged 1 commit into
mainfrom
fix/empty-cell-text-pour
Jun 18, 2026
Merged

fix(canvas): seed an empty paragraph when pouring text into a fresh cell#3
drietsch merged 1 commit into
mainfrom
fix/empty-cell-text-pour

Conversation

@drietsch

Copy link
Copy Markdown
Contributor

Problem

Pouring text into a freshly-created, empty table cell panicked with index out of bounds: len 0 index 0apply_insert_text assumed the cell's text stream already had at least one paragraph.

Fix

apply_insert_text seeds an empty Paragraph when the cell stream is empty, so the first insert into a new cell lands cleanly.

⚠️ Ships PAIRED

This is one half of the native-table cell-pour fix. It must merge together with plugin-sheets#fix/tablecell-id — that bundle's new two-lane pourCellContent() would panic against an unpatched core. Do not publish one without the other.

🤖 Generated with Claude Code

… cell

A table cell created by `insertTable` carries ZERO paragraphs. The first text
pour into it (the paged.sheet cell pour) located the end of an empty stream —
`locate` pins an empty `paragraphs` to `paragraph_idx 0` via
`saturating_sub(1)` — and `insert_one_segment` then indexed `paragraphs[0]` on
an empty slice, panicking with `index out of bounds: the len is 0 but the
index is 0` (mutate.rs:264). The panic poisoned the wasm, so every later call
failed with the wasm-bindgen "recursive use of an object" guard — a wall of
errors that masked the real cause.

`apply_insert_text` now seeds one empty `Paragraph` when the resolved cell (or
any) paragraph stream is empty, so the first write has a stream to land in.

Tests: a new cell_text regression (insertTable → insertText into the fresh
empty cell does not panic) + a tablecell_wire pin of the cell-pour op shapes.

Co-Authored-By: Dietmar Rietsch <dietmar.rietsch@andthenext.at>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@drietsch

Copy link
Copy Markdown
Contributor Author

⚠️ Ships paired with paged-media/plugin-sheets#1 — the sheet bundle's two-lane pour panics against an unpatched core. Merge + publish together.

@drietsch drietsch merged commit a596662 into main Jun 18, 2026
9 of 11 checks passed
@drietsch drietsch deleted the fix/empty-cell-text-pour branch June 18, 2026 12:06
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