Skip to content

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

:bug: Abnormal heading block update time https://github.com/siyuan-note/siyuan/issues/11985

Daniel5e2f5859c643
diff --git a/kernel/treenode/node.go b/kernel/treenode/node.go
index d9301ae1e3..40de7b3f6a 100644
--- a/kernel/treenode/node.go
+++ b/kernel/treenode/node.go
@@ -18,6 +18,9 @@ package treenode
import (
"bytes"
+ "strings"
+ "sync"
+
"github.com/88250/gulu"
"github.com/88250/lute"
"github.com/88250/lute/ast"
@@ -26,12 +29,9 @@ import (
"github.com/88250/lute/parse"
"github.com/88250/lute/render"
"github.com/88250/vitess-sqlparser/sqlparser"
- "github.com/emirpasic/gods/sets/hashset"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/util"
- "strings"
- "sync"
)
func GetEmbedBlockRef(embedNode *ast.Node) (blockRefID string) {
@@ -229,7 +229,6 @@ func CountBlockNodes(node *ast.Node) (ret int) {
func ParentNodesWithHeadings(node *ast.Node) (parents []*ast.Node) {
const maxDepth = 255
i := 0
- headingIDs := hashset.New()
for n := node; nil != n; n = n.Parent {
parent := n.Parent
if maxDepth < i {
@@ -246,9 +245,13 @@ func ParentNodesWithHeadings(node *ast.Node) (parents []*ast.Node) {
// The heading block update time is refreshed after editing the blocks under the heading https://github.com/siyuan-note/siyuan/issues/11374
parentHeadingLevel := 7
for prev := n.Previous; nil != prev; prev = prev.Previous {
- if ast.NodeHeading == prev.Type && prev.HeadingLevel < parentHeadingLevel && !headingIDs.Contains(prev.ID) {
+ if ast.NodeHeading == prev.Type {
+ if prev.HeadingLevel >= parentHeadingLevel {
+ break
+ }
+
parents = append(parents, prev)
- headingIDs.Add(prev.ID)
+ parentHeadingLevel = prev.HeadingLevel
}
}