From f3c61a59c22bfa3f2bf84645809fd74843c37e38 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilev Date: Tue, 18 Oct 2022 22:26:34 +0800 Subject: [PATCH] fix bug native calls were not selected on click --- src/calltree.js | 6 +++--- test/test.js | 32 +++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/calltree.js b/src/calltree.js index a3dfce7..8882b3f 100644 --- a/src/calltree.js +++ b/src/calltree.js @@ -430,13 +430,13 @@ export const toggle_expanded = (state, is_exp) => { const click = (state, id) => { const node = find_node(root_calltree_node(state), n => n.id == id) - // Effects are intentionally discarded, correct `set_caret_position` will be - // applied in `toggle_expanded` const {state: nextstate, effects} = jump_calltree_node(state, node) if(is_expandable(node)) { + // `effects` are intentionally discarded, correct `set_caret_position` will + // be applied in `toggle_expanded` return toggle_expanded(nextstate) } else { - return {state: nextstate} + return {state: nextstate, effects} } } diff --git a/test/test.js b/test/test.js index d336d8f..db44a18 100644 --- a/test/test.js +++ b/test/test.js @@ -1302,6 +1302,36 @@ const y = x()` assert_equal(map_expanded.children.length, 3) }), + test('click native calltree node', () => { + const s = test_initial_state(`Object.fromEntries([])`) + const index = 0 // Where call starts + const call = root_calltree_node(s).children[0] + const {state, effects} = COMMANDS.calltree.click(s, call.id) + assert_equal( + effects, + [ + { type: 'set_caret_position', args: [ index ] }, + { + "type": "embed_value_explorer", + "args": [ + { + index, + result: { + "ok": true, + "value": { + "*arguments*": [ + [] + ], + "*return*": {} + } + } + } + ] + } + ] + ) + }), + test('jump_calltree_location' , () => { const code = ` const x = foo => foo + 1; @@ -1794,7 +1824,7 @@ const y = x()` assert_equal(s2.effects.type, 'unembed_value_explorer') }), - test_only('move_cursor concise fn throws', () => { + test('move_cursor concise fn throws', () => { const code = ` const throws = () => { throw new Error('boom')