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 {
|
||||
|
||||
const next = (n, path) => {
|
||||
if(n == root_calltree_node(state)) {
|
||||
if(n.id == 'calltree') {
|
||||
return null
|
||||
}
|
||||
const [parent, ...grandparents] = path
|
||||
@@ -334,10 +334,14 @@ const arrow_down = state => {
|
||||
|
||||
next_node = next(
|
||||
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
|
||||
? state
|
||||
: jump_calltree_node(state, next_node)
|
||||
@@ -348,15 +352,11 @@ const arrow_up = state => {
|
||||
if(current == root_calltree_node(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 =>
|
||||
c == current
|
||||
)
|
||||
const next_child = parent.children[child_index - 1]
|
||||
let next_node
|
||||
if(next_child == null) {
|
||||
next_node = parent
|
||||
} else {
|
||||
const last = node => {
|
||||
if(
|
||||
!is_expandable(node)
|
||||
@@ -368,6 +368,12 @@ const arrow_up = state => {
|
||||
return last(node.children[node.children.length - 1])
|
||||
}
|
||||
}
|
||||
let next_node
|
||||
if(next_child == null) {
|
||||
next_node = parent.id == 'async_calls'
|
||||
? last(root_calltree_node(state))
|
||||
: parent
|
||||
} else {
|
||||
next_node = last(next_child)
|
||||
}
|
||||
return jump_calltree_node(state, next_node)
|
||||
@@ -377,11 +383,11 @@ const arrow_left = state => {
|
||||
const current = state.current_calltree_node
|
||||
const is_expanded = state.calltree_node_is_expanded[current.id]
|
||||
if(!is_expandable(current) || !is_expanded) {
|
||||
if(current != root_calltree_node(state)) {
|
||||
const [parent] = path_to_root(root_calltree_node(state), current)
|
||||
return jump_calltree_node(state, parent)
|
||||
} else {
|
||||
const [parent] = path_to_root(state.calltree, current)
|
||||
if(parent.id == 'calltree' || parent.id == 'async_calls') {
|
||||
return state
|
||||
} else {
|
||||
return jump_calltree_node(state, parent)
|
||||
}
|
||||
} else {
|
||||
return toggle_expanded(state)
|
||||
|
||||
@@ -2355,6 +2355,9 @@ const y = x()`
|
||||
// Navigate logs
|
||||
const nav = COMMANDS.calltree.navigate_logs_position(expanded, 0)
|
||||
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