mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-03 08:50:02 -06:00
* fix(engine): saturate page parameters on 32-bit and wasm (#3676) The file.exportPng and edit.goto paths cast a u64 page to usize and subtracted one. On 32-bit and wasm, page 2^32 truncated to 0 and the subtraction wrapped to page 1 (a debug panic). Add p::page_index, which saturates instead of wrapping, and use it in both engine paths. The MCP render path already has the same guard on main; the new tests also pin that behavior. Regression tests cover the helper, Go To, PNG export and the MCP render path. * fix(engine): guard caret.set page cast too (#3676) caret.set takes a 0-based page; pg as usize truncated on 32-bit and wasm and could select page 0. Use the same checked conversion and add a regression test. --------- Co-authored-by: Brandon Thomas <echelon@gmail.com>