Skip to content

Commit

Permalink
🐛 Abnormal heading block update time siyuan-note#11985
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jul 16, 2024
1 parent 8bf6646 commit 5e2f585
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions kernel/treenode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ package treenode

import (
"bytes"
"strings"
"sync"

"github.com/88250/gulu"
"github.com/88250/lute"
"github.com/88250/lute/ast"
Expand All @@ -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) {
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
}

Expand Down

0 comments on commit 5e2f585

Please sign in to comment.