Skip to content

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

:bug: 搜索处于折叠状态的块时未聚焦显示结果 Fix https://github.com/siyuan-note/siyuan/issues/7252

Liang Ding3fb296c88c1d
diff --git a/kernel/api/block.go b/kernel/api/block.go
index 13269d5dd2..71d0a54e6c 100644
--- a/kernel/api/block.go
+++ b/kernel/api/block.go
@@ -154,19 +154,7 @@ func checkBlockFold(c *gin.Context) {
}
id := arg["id"].(string)
- b, err := model.GetBlock(id, nil)
- if errors.Is(err, filelock.ErrUnableAccessFile) {
- ret.Code = 2
- ret.Data = id
- return
- }
- if errors.Is(err, model.ErrIndexing) {
- ret.Code = 0
- ret.Data = false
- return
- }
-
- ret.Data = nil != b && "1" == b.IAL["fold"]
+ ret.Data = model.IsBlockFolded(id)
}
func checkBlockExist(c *gin.Context) {
diff --git a/kernel/model/block.go b/kernel/model/block.go
index d0775aeb76..b9b51f668f 100644
--- a/kernel/model/block.go
+++ b/kernel/model/block.go
@@ -87,6 +87,22 @@ type Path struct {
Created string `json:"created"` // 创建时间
}
+func IsBlockFolded(id string) bool {
+ for i := 0; i < 32; i++ {
+ b, _ := getBlock(id, nil)
+ if nil == b {
+ return true
+ }
+
+ if "1" == b.IAL["fold"] {
+ return true
+ }
+
+ id = b.ParentID
+ }
+ return false
+}
+
func RecentUpdatedBlocks() (ret []*Block) {
ret = []*Block{}