diff --git a/src/calltree.js b/src/calltree.js index 2b19a93..85d8845 100644 --- a/src/calltree.js +++ b/src/calltree.js @@ -851,7 +851,14 @@ const select_error = state => { const error_origin = find_node(node, n => has_error(n) && ( - n.children == null || n.children.every(c => !has_error(c)) + n.children == null + || + n.children.every(c => + !has_error(c) + || + // Error in native fn + is_native_fn(c) && c.children == null + ) ) ) diff --git a/test/test.js b/test/test.js index 1677ff6..cbe6e3c 100644 --- a/test/test.js +++ b/test/test.js @@ -2508,6 +2508,23 @@ const y = x()` assert_equal(current_cursor_position(found_err_state), code.indexOf('throw')) }), + test('select_error in native fn', () => { + const code = ` + function x() { + Object.entries(null) + } + + x() + ` + const i = test_initial_state(code) + const {state: found_err_state} = COMMANDS.calltree.select_error(i) + assert_equal(found_err_state.active_calltree_node.fn.name, 'x') + assert_equal( + current_cursor_position(found_err_state), + code.indexOf('Object.entries') + ) + }), + test('move_cursor arguments', () => { const code = ` const x = (a, b) => { }