mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
navigate async calls
This commit is contained in:
@@ -317,7 +317,7 @@ const arrow_down = state => {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
const next = (n, path) => {
|
const next = (n, path) => {
|
||||||
if(n == root_calltree_node(state)) {
|
if(n.id == 'calltree') {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const [parent, ...grandparents] = path
|
const [parent, ...grandparents] = path
|
||||||
@@ -334,10 +334,14 @@ const arrow_down = state => {
|
|||||||
|
|
||||||
next_node = next(
|
next_node = next(
|
||||||
current,
|
current,
|
||||||
path_to_root(root_calltree_node(state), current)
|
path_to_root(state.calltree, current)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(next_node?.id == 'async_calls') {
|
||||||
|
next_node = next_node.children[0]
|
||||||
|
}
|
||||||
|
|
||||||
return next_node == null
|
return next_node == null
|
||||||
? state
|
? state
|
||||||
: jump_calltree_node(state, next_node)
|
: jump_calltree_node(state, next_node)
|
||||||
@@ -348,26 +352,28 @@ const arrow_up = state => {
|
|||||||
if(current == root_calltree_node(state)) {
|
if(current == root_calltree_node(state)) {
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
const [parent] = path_to_root(root_calltree_node(state), current)
|
const [parent] = path_to_root(state.calltree, current)
|
||||||
const child_index = parent.children.findIndex(c =>
|
const child_index = parent.children.findIndex(c =>
|
||||||
c == current
|
c == current
|
||||||
)
|
)
|
||||||
const next_child = parent.children[child_index - 1]
|
const next_child = parent.children[child_index - 1]
|
||||||
|
const last = node => {
|
||||||
|
if(
|
||||||
|
!is_expandable(node)
|
||||||
|
|| !state.calltree_node_is_expanded[node.id]
|
||||||
|
|| node.children == null
|
||||||
|
) {
|
||||||
|
return node
|
||||||
|
} else {
|
||||||
|
return last(node.children[node.children.length - 1])
|
||||||
|
}
|
||||||
|
}
|
||||||
let next_node
|
let next_node
|
||||||
if(next_child == null) {
|
if(next_child == null) {
|
||||||
next_node = parent
|
next_node = parent.id == 'async_calls'
|
||||||
|
? last(root_calltree_node(state))
|
||||||
|
: parent
|
||||||
} else {
|
} else {
|
||||||
const last = node => {
|
|
||||||
if(
|
|
||||||
!is_expandable(node)
|
|
||||||
|| !state.calltree_node_is_expanded[node.id]
|
|
||||||
|| node.children == null
|
|
||||||
) {
|
|
||||||
return node
|
|
||||||
} else {
|
|
||||||
return last(node.children[node.children.length - 1])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
next_node = last(next_child)
|
next_node = last(next_child)
|
||||||
}
|
}
|
||||||
return jump_calltree_node(state, next_node)
|
return jump_calltree_node(state, next_node)
|
||||||
@@ -377,11 +383,11 @@ const arrow_left = state => {
|
|||||||
const current = state.current_calltree_node
|
const current = state.current_calltree_node
|
||||||
const is_expanded = state.calltree_node_is_expanded[current.id]
|
const is_expanded = state.calltree_node_is_expanded[current.id]
|
||||||
if(!is_expandable(current) || !is_expanded) {
|
if(!is_expandable(current) || !is_expanded) {
|
||||||
if(current != root_calltree_node(state)) {
|
const [parent] = path_to_root(state.calltree, current)
|
||||||
const [parent] = path_to_root(root_calltree_node(state), current)
|
if(parent.id == 'calltree' || parent.id == 'async_calls') {
|
||||||
return jump_calltree_node(state, parent)
|
|
||||||
} else {
|
|
||||||
return state
|
return state
|
||||||
|
} else {
|
||||||
|
return jump_calltree_node(state, parent)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return toggle_expanded(state)
|
return toggle_expanded(state)
|
||||||
|
|||||||
@@ -2355,6 +2355,9 @@ const y = x()`
|
|||||||
// Navigate logs
|
// Navigate logs
|
||||||
const nav = COMMANDS.calltree.navigate_logs_position(expanded, 0)
|
const nav = COMMANDS.calltree.navigate_logs_position(expanded, 0)
|
||||||
assert_equal(nav.state.current_calltree_node.is_log, true)
|
assert_equal(nav.state.current_calltree_node.is_log, true)
|
||||||
|
|
||||||
|
const nav2 = COMMANDS.calltree.arrow_left(nav.state)
|
||||||
|
assert_equal(nav2.state.current_calltree_node.fn.name, 'fn2')
|
||||||
}),
|
}),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user