Skip to content

Commit e06a7b2

Browse files
committed
WASM REPL: make the magic ctrl+c string vary with each run
1 parent 4dcc6fb commit e06a7b2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Tools/wasm/emscripten/web_example/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
integrity="sha512-kmA5vhcxOkZI0ReiKJMGNb8/KKbgbExIlnt6aXuPtl86AgHBEi6OHHOz2wsTazBDGZKxe7fmiE+pIuZJQks4+A=="
5757
></script>
5858
<script type="module">
59+
const _magic_ctrlc_string = "__WASM_REPL_CTRLC_" + (Date.now()) + "__";
5960
class WorkerManager {
6061
constructor(
6162
workerURL,
@@ -261,7 +262,7 @@
261262
this.input = "";
262263
this.cursorPosition = 0;
263264
this.historyIndex = -1;
264-
this.resolveInput("__WASM_REPL_CTRLC__\n");
265+
this.resolveInput(_magic_ctrlc_string + "\n");
265266
break;
266267
case "\x09": // TAB
267268
this.handleTab();
@@ -472,7 +473,7 @@
472473
this.resolveInput = (value) => {
473474
if (
474475
value.replace(/\s/g, "").length != 0 &&
475-
value != "__WASM_REPL_CTRLC__\n"
476+
value != _magic_ctrlc_string + "\n"
476477
) {
477478
if (this.historyIndex !== -1) {
478479
this.historyBuffer[this.historyIndex] =
@@ -600,7 +601,7 @@
600601
601602
def _interrupt_aware_input(prompt=''):
602603
line = builtins.input(prompt)
603-
if line.strip() == '__WASM_REPL_CTRLC__':
604+
if line.strip() == "${_magic_ctrlc_string}":
604605
raise KeyboardInterrupt()
605606
return line
606607

0 commit comments

Comments
 (0)