This commit is contained in:
Dmitry Vasilev
2022-12-02 19:25:51 +08:00
parent f561e9df7d
commit 9e9400ab24
3 changed files with 19 additions and 3 deletions

View File

@@ -201,10 +201,18 @@ const external_imports_loaded = (
toplevel = false
}
return modules_evaluated(state, result, node, toplevel)
if(result.then != null) {
return {...state,
eval_modules_state: {
promise: result, node, toplevel,
}
}
} else {
return eval_modules_finished(state, result, node, toplevel)
}
}
const modules_evaluated = (state, result, node, toplevel) => {
const eval_modules_finished = (state, result, node, toplevel) => {
const next = apply_eval_result(state, result)
let active_calltree_node
@@ -837,6 +845,7 @@ export const COMMANDS = {
move_cursor,
eval_selection,
external_imports_loaded,
eval_modules_finished,
on_deferred_call,
calltree: calltree_commands,
}

7
src/effects.js vendored
View File

@@ -176,6 +176,13 @@ export const render_common_side_effects = async (prev, next, command, ui) => {
load_external_imports(next)
}
if(prev.eval_modules_state != next.eval_modules_state) {
const s = next.eval_modules_state
s.promise.then(result => {
exec('eval_modules_finished', result, s.node, s.toplevel)
})
}
if(prev.parse_result != next.parse_result) {
render_parse_result(ui, next)
}

View File

@@ -2589,7 +2589,7 @@ const y = x()`
assert_equal(get_deferred_calls(result), null)
}),
test_only('async/await', () => {
test('async/await', () => {
const code = `
const x = async () => 123
const y = async () => await x()