╭ changed ──────────╮ │src/embed/script.js│ ╰───────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │294 function sendTextInputValue(focusId, value) { │ │295 const bytes = encoder.encode(value); │ │296 const ptr = wasmInstance.exports._alloc(bytes.length); │ │297 - new Uint8Array(wasmInstance.exports.memory.buffer, ptr, bytes.length).set(bytes); │ │297 + // an empty allocation's pointer lies outside the buffer, so a view onto it │ │298 + // would throw and leave the wasm holding the old value │ │299 + if (bytes.length > 0) { │ │300 + new Uint8Array(wasmInstance.exports.memory.buffer, ptr, bytes.length).set(bytes);│ │301 + } │ │302 wasmInstance.exports._setTextInputValue(focusId, ptr, bytes.length); │ │303 wasmInstance.exports._tick(minRows(), maxCols()); │ │304 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │366 wasmInstance.exports._tick(minRows(), maxCols()); │ │367 return; │ │368 } else if (tag === "INPUT" && event.key === "Enter") { │ │365 - // enter in a text input never submits the form; only the │ │366 - // submit button does │ │369 + // enter in a form's text input never submits it; only the │ │370 + // submit button does. an input outside a form has no submit │ │371 + // button, so the TUI handles its enter instead. │ │372 event.preventDefault(); │ │373 + if (!document.activeElement.form) { │ │374 + wasmInstance.exports._onKeyDown(event.keyCode); │ │375 + wasmInstance.exports._tick(minRows(), maxCols()); │ │376 + } │ │377 return; │ │378 } else if (tag === "INPUT" && (event.key === "ArrowUp" || event.key === "ArrowDown")) {│ │379 // up/down moves between widgets; left/right stay in the input │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯