From 934e0e16ac4d691e64f5b07d7210c7b43200f340 Mon Sep 17 00:00:00 2001 From: FreezePhoenix <24441367+FreezePhoenix@users.noreply.github.com> Date: Sat, 27 Jan 2024 14:39:33 -0500 Subject: [PATCH] Fix small bug with async code snippets If a code snippet used await, and had a line comment on the last line, it would fail to run: ```js await sleep(1000); show_json(100); // show_json(200); ``` This is because the line comment would end up cutting off the end of the async function wrapper that `code_eval` creates. --- js/functions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/functions.js b/js/functions.js index f06b212..d1168d7 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1663,7 +1663,7 @@ function code_eval(snippet) { var f="eval"; if(snippet.search("output=")!=-1 || snippet.search("json_output=")!=-1) f="eval_s"; - if(snippet.search("await")!=-1) snippet="(async () => {"+snippet+"})()"; + if(snippet.search("await")!=-1) snippet="(async () => {"+snippet+"\n})()"; if(code_active) { call_code_function(f,snippet); @@ -7006,4 +7006,4 @@ function electron_add_webview(url) { if(!url) url="http://thegame.com/character/GG/in/EU/I/"; $("body").append(""); -} \ No newline at end of file +}