diff --git a/main_test.go b/main_test.go index 09fe9628..30fb4e65 100644 --- a/main_test.go +++ b/main_test.go @@ -1,3 +1,6 @@ +//go:build !tinygo +// +build !tinygo + package main_test import ( diff --git a/wasm/grol_wasm.html b/wasm/grol_wasm.html index dfb166fb..c8e46a58 100644 --- a/wasm/grol_wasm.html +++ b/wasm/grol_wasm.html @@ -73,6 +73,7 @@ if (output && output.result !== undefined) { // Write the result to the output textarea document.getElementById('output').value = output.result; + document.getElementById('input').value = output.formatted; document.getElementById('errors').value = output.errors.join("\n"); } else { document.getElementById('errors').value = "Unexpected runtime error, see JS console"; @@ -85,6 +86,7 @@ } finally { inst = await WebAssembly.instantiate(mod, go.importObject); // reset instance } + resizeTextarea(document.getElementById('input')); resizeTextarea(document.getElementById('output')); resizeTextarea(document.getElementById('errors')); } @@ -102,21 +104,25 @@
- Hit enter or click + Hit enter or click (will also format the code)
diff --git a/wasm/wasm_main.go b/wasm/wasm_main.go index 84f7b48f..edde5984 100644 --- a/wasm/wasm_main.go +++ b/wasm/wasm_main.go @@ -22,7 +22,7 @@ func jsEval(this js.Value, args []js.Value) interface{} { return "ERROR: number of arguments doesn't match" } input := args[0].String() - res, errs := repl.EvalString(input) + res, errs, formatted := repl.EvalString(input) result := make(map[string]any) result["result"] = res // transfer errors to []any (!) @@ -31,6 +31,7 @@ func jsEval(this js.Value, args []js.Value) interface{} { anyErrs[i] = v } result["errors"] = anyErrs + result["formatted"] = formatted return result }