fix bug native calls were not selected on click

This commit is contained in:
Dmitry Vasilev
2022-10-18 22:26:34 +08:00
parent 359b2772f6
commit f3c61a59c2
2 changed files with 34 additions and 4 deletions

View File

@@ -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}
}
}

View File

@@ -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')