Fixing the invalid code bricking the UI

Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
Jakub Doka 2024-12-14 15:33:11 +01:00
parent 5aeeedbdce
commit 91e35b72ee
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143

View file

@ -336,10 +336,10 @@ async function fmt(target) {
const instance = await getFmtInstance(); const instance = await getFmtInstance();
const decoder = new TextDecoder('utf-8'); const decoder = new TextDecoder('utf-8');
const fmt = modifyCode(instance, code, 'fmt'); const fmt = modifyCode(instance, code, 'fmt');
if (typeof fmt !== "string") never() if (typeof fmt !== "string") return;
const codeBytes = new TextEncoder().encode(fmt); const codeBytes = new TextEncoder().encode(fmt);
const tok = modifyCode(instance, fmt, 'tok'); const tok = modifyCode(instance, fmt, 'tok');
if (!(tok instanceof Uint8Array)) never(); if (!(tok instanceof Uint8Array)) return;
target.innerHTML = ''; target.innerHTML = '';
let start = 0; let start = 0;
let kind = tok[0]; let kind = tok[0];