Skip to content

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

:art: 状态栏显示选中内容的字数 https://github.com/siyuan-note/siyuan/issues/4932

Liang Ding50b76a8d9f7a
diff --git a/kernel/model/file.go b/kernel/model/file.go
index b21f88dfe6..ccc7714027 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)