From bc8ae5a0ba75706cfa63f7a0db97cfdb5a978458 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilev Date: Tue, 3 Jan 2023 02:01:40 +0800 Subject: [PATCH] fix move_cursor before eval finished --- src/cmd.js | 4 ++-- test/test.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd.js b/src/cmd.js index 7ea902f..fe9b420 100644 --- a/src/cmd.js +++ b/src/cmd.js @@ -742,8 +742,8 @@ const move_cursor = (s, index) => { return {state: with_cursor} } - if(s.loading_external_imports_state != null) { - // Code will be executed when imports will load, do not do it right now + if(s.loading_external_imports_state != null || s.eval_modules_state != null) { + // Code will be executed when imports will load, do not do it right now return {state: with_cursor} } diff --git a/test/test.js b/test/test.js index e9e25af..a96caf4 100644 --- a/test/test.js +++ b/test/test.js @@ -2943,12 +2943,12 @@ const y = x()` ) }), - /* TODO - test('async/await move_cursor bug', async () => { - const i = await test_initial_state_async(` + test('async/await move_cursor before code evaluated', async () => { + const i = test_initial_state(` await new Promise(resolve => globalThis.setTimeout(resolve, 1)) `) + const moved = COMMANDS.move_cursor(i, 0) + // No assertion, must not throw }), - */ ]