mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
fix bug native calls were not selected on click
This commit is contained in:
@@ -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}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
32
test/test.js
32
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')
|
||||
|
||||
Reference in New Issue
Block a user