From 50b76a8d9f7a6ea87bfbde37632ec89a7c9cab53 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 28 Jun 2022 22:15:32 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E7=8A=B6=E6=80=81=E6=A0=8F=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=80=89=E4=B8=AD=E5=86=85=E5=AE=B9=E7=9A=84=E5=AD=97?= =?UTF-8?q?=E6=95=B0=20https://github.com/siyuan-note/siyuan/issues/4932?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/file.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/model/file.go b/kernel/model/file.go index b21f88dfe..ccc771402 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -372,10 +372,21 @@ func ContentWordCount(content string) (runeCount, wordCount int) { } func BlocksWordCount(ids []string) (runeCount, wordCount int) { + trees := map[string]*parse.Tree{} // 缓存 for _, id := range ids { - tree, _ := loadTreeByBlockID(id) + bt := treenode.GetBlockTree(id) + if nil == bt { + util.LogWarnf("block tree not found [%s]", id) + continue + } + + tree := trees[bt.RootID] if nil == tree { - return + tree, _ = LoadTree(bt.BoxID, bt.Path) + if nil == tree { + continue + } + trees[bt.RootID] = tree } node := treenode.GetNodeInTree(tree, id)