diff --git a/src/calltree.js b/src/calltree.js index 305ff87..dcc062c 100644 --- a/src/calltree.js +++ b/src/calltree.js @@ -339,7 +339,11 @@ const arrow_down = state => { } if(next_node?.id == 'async_calls') { - next_node = next_node.children[0] + if(next_node.children == null) { + next_node = null + } else { + next_node = next_node.children[0] + } } return next_node == null diff --git a/test/test.js b/test/test.js index b1bf08b..3cdcc8a 100644 --- a/test/test.js +++ b/test/test.js @@ -2363,6 +2363,15 @@ const y = x()` const {state: i, on_async_call} = test_async_calls_state(code) + // When there are no async calls, and we press arrow down, nothing should + // happen + const no_async_down = + COMMANDS.calltree.arrow_down( + COMMANDS.calltree.arrow_down(i).state + ) + + assert_equal(no_async_down.current_calltree_node.fn.name, 'normal_call') + const after_async_calls = [1, 2, 3].reduce( (s, a) => { // Make async calls