mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-26 18:26:09 +01:00
🎨 Improve doc dynamic loading
This commit is contained in:
parent
111608fd37
commit
57f9c4ddc1
1 changed files with 13 additions and 0 deletions
|
|
@ -681,6 +681,19 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
|
|||
if 1 > len(nodes) {
|
||||
// 按 mode 加载兜底
|
||||
nodes, eof = loadNodesByMode(node, inputIndex, mode, size, isDoc, isHeading)
|
||||
} else {
|
||||
// 文档块没有指定 index 时需要计算 index,否则初次打开文档时 node-index 会为 0,导致首次 Ctrl+Home 无法回到顶部
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
index++
|
||||
if nodes[0].ID == n.ID {
|
||||
return ast.WalkStop
|
||||
}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
}
|
||||
} else {
|
||||
nodes, eof = loadNodesByMode(node, inputIndex, mode, size, isDoc, isHeading)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue