Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve the behavior of `Jump to parent block` in lists https://github.com/siyuan-note/siyuan/issues/16516

Daniel172615b0e3c4
diff --git a/kernel/model/block.go b/kernel/model/block.go
index 1eae22dcd6..1425cb146c 100644
--- a/kernel/model/block.go
+++ b/kernel/model/block.go
@@ -230,14 +230,26 @@ func GetBlockSiblingID(id string) (parent, previous, next string) {
return
}
- if ast.NodeListItem != parentBlock.Type {
- if parentBlock = treenode.ParentBlock(parentBlock); nil != parentBlock {
- parent = parentBlock.ID
- if ast.NodeDocument == parentBlock.Type {
- parent = treenode.FirstLeafBlock(parentBlock).ID
+ parentCount := 0
+ for ; nil != parentBlock; parentBlock = treenode.ParentBlock(parentBlock) {
+ if ast.NodeDocument == parentBlock.Type {
+ break
+ }
+
+ if ast.NodeList == parentBlock.Type || ast.NodeBlockquote == parentBlock.Type || ast.NodeSuperBlock == parentBlock.Type || ast.NodeCallout == parentBlock.Type {
+ parentCount++
+ continue
+ }
+
+ if ast.NodeListItem == parentBlock.Type {
+ if 1 > parentCount {
+ parentBlock = treenode.ParentBlock(parentBlock)
}
+ parentBlock = treenode.ParentBlock(parentBlock)
}
+ break
}
+ parent = treenode.FirstLeafBlock(parentBlock).ID
parentBlock = treenode.ParentBlock(current)
for ; nil != parentBlock; parentBlock = treenode.ParentBlock(parentBlock) {