An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: The parent block field of the blocks under the heading block is calculated incorrectly https://github.com/siyuan-note/siyuan/issues/9869
Daniela785cd15c070
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex e149f3345d..96560f9694 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -314,6 +314,8 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {headingChildren = treenode.GetHeadingFold(headingChildren)}+ refreshHeadingChildrenUpdated(srcNode, time.Now().Format("20060102150405"))+var srcEmptyList *ast.Nodeif ast.NodeListItem == srcNode.Type && srcNode.Parent.FirstChild == srcNode && srcNode.Parent.LastChild == srcNode {// 列表中唯一的列表项被移除后,该列表就为空了@@ -366,6 +368,8 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {srcEmptyList.Unlink()}+ refreshHeadingChildrenUpdated(srcNode, time.Now().Format("20060102150405"))+refreshUpdated(srcNode)refreshUpdated(srcTree.Root)if err = tx.writeTree(srcTree); nil != err {@@ -444,6 +448,8 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {}}+ refreshHeadingChildrenUpdated(srcNode, time.Now().Format("20060102150405"))+refreshUpdated(srcNode)refreshUpdated(srcTree.Root)if err = tx.writeTree(srcTree); nil != err {@@ -752,6 +758,9 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {// 列表块撤销状态异常 https://github.com/siyuan-note/siyuan/issues/3985node.Next.Unlink()}++ refreshHeadingChildrenUpdated(node, time.Now().Format("20060102150405"))+node.Unlink()if nil != parent && ast.NodeListItem == parent.Type && nil == parent.FirstChild {// 保持空列表项@@ -961,6 +970,8 @@ func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {}}+ refreshHeadingChildrenUpdated(insertedNode, time.Now().Format("20060102150405"))+createdUpdated(insertedNode)tx.nodes[insertedNode.ID] = insertedNodeif err = tx.writeTree(tree); nil != err {@@ -1048,14 +1059,7 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {treenode.MoveFoldHeading(updatedNode, oldNode)}- if ast.NodeHeading == oldNode.Type && ast.NodeHeading != updatedNode.Type {- // 将标题块更新为非标题块时需要更新下方块的 parent id- children := treenode.HeadingChildren(oldNode)- updated := time.Now().Format("20060102150405")- for _, child := range children {- child.SetIALAttr("updated", updated)- }- }+ refreshHeadingChildrenUpdated(oldNode, time.Now().Format("20060102150405"))cache.PutBlockIAL(updatedNode.ID, parse.IAL2Map(updatedNode.KramdownIAL))@@ -1064,15 +1068,7 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {oldNode.Unlink()createdUpdated(updatedNode)- if ast.NodeHeading != oldNode.Type && ast.NodeHeading == updatedNode.Type {- // 将非标题块更新为标题块时需要更新下方块的 parent id- // The parent block field of the blocks under the heading block is calculated incorrectly https://github.com/siyuan-note/siyuan/issues/9869- children := treenode.HeadingChildren(updatedNode)- updated := updatedNode.IALAttr("updated")- for _, child := range children {- child.SetIALAttr("updated", updated)- }- }+ refreshHeadingChildrenUpdated(updatedNode, updatedNode.IALAttr("updated"))tx.nodes[updatedNode.ID] = updatedNodeif err = tx.writeTree(tree); nil != err {@@ -1085,6 +1081,19 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {return}+func refreshHeadingChildrenUpdated(heading *ast.Node, updated string) {+ if nil == heading || ast.NodeHeading != heading.Type {+ return+ }++ // 将非标题块更新为标题块时需要更新下方块的 parent id+ // The parent block field of the blocks under the heading block is calculated incorrectly https://github.com/siyuan-note/siyuan/issues/9869+ children := treenode.HeadingChildren(heading)+ for _, child := range children {+ child.SetIALAttr("updated", updated)+ }+}+func upsertAvBlockRel(node *ast.Node) {ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {if !entering {