From cff3266ce280e67011f727f7bdcca83c38badd18 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 25 Oct 2022 15:47:27 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=9D=97=E6=BB=9A=E5=8A=A8=E6=9D=A1?= =?UTF-8?q?=E8=B7=9F=E9=9A=8F=E6=BB=9A=E5=8A=A8=20https://github.com/siyua?= =?UTF-8?q?n-note/siyuan/issues/4612?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/blockinfo.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.go index af20d8e51..67f9bcce1 100644 --- a/kernel/model/blockinfo.go +++ b/kernel/model/blockinfo.go @@ -163,6 +163,10 @@ func GetBlockIndex(id string) (ret int) { return } + rootChild := node + for ; nil == rootChild.Parent || ast.NodeDocument != rootChild.Parent.Type; rootChild = rootChild.Parent { + } + ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus { if !entering { return ast.WalkContinue @@ -173,7 +177,7 @@ func GetBlockIndex(id string) (ret int) { } ret++ - if node == n { + if n.ID == rootChild.ID { return ast.WalkStop } return ast.WalkContinue