Limit the "edges" of the grid.

This commit is contained in:
Yaro Kasear 2026-01-14 11:20:01 -06:00
parent 41fafae501
commit 27a29d9c66

View file

@ -166,7 +166,17 @@ function initGridWidget(root, opts = {}) {
let prevLineEnd = null; let prevLineEnd = null;
const toInt = (n) => Math.round(Number(n) * q); const MAX_DOC_COORD = 1_000_000;
const MAX_INT = MAX_DOC_COORD * q;
const clampInt = (v) => {
if (!Number.isFinite(v)) return 0;
if (v > MAX_INT) return MAX_INT;
if (v < -MAX_INT) return -MAX_INT;
return v;
};
const toInt = (n) => clampInt(Math.round(Number(n) * q));
const resetRun = () => { const resetRun = () => {
prevKind = null; prevKind = null;