Skip to content

Commit

Permalink
🎨 Simplify document block paths in search results #13364
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 4, 2024
1 parent a1c21e9 commit 4a19605
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions kernel/model/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets,
ret = []*Block{}
}

// 在 hPath 中加入笔记本名 Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378
prependNotebookNameInHPath(ret)
filterSelfHPath(ret)
return
}

Expand Down Expand Up @@ -423,15 +423,15 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets,
newDoc = true
}

// 在 hPath 中加入笔记本名 Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378
prependNotebookNameInHPath(ret)
// 简化块引搜索列表中的文档块路径 Simplify document block paths in block ref search list https://github.com/siyuan-note/siyuan/issues/13364
// 文档块不显示自己的路径(最后一层)
filterSelfHPath(ret)
return
}

func filterSelfHPath(blocks []*Block) {
// 简化搜索结果列表中的文档块路径 Simplify document block paths in search results https://github.com/siyuan-note/siyuan/issues/13364
// 文档块不显示自己的路径(最后一层)

for _, b := range blocks {
if b.IsDoc() {
b.HPath = strings.TrimSuffix(b.HPath, path.Base(b.HPath))
Expand All @@ -440,6 +440,8 @@ func filterSelfHPath(blocks []*Block) {
}

func prependNotebookNameInHPath(blocks []*Block) {
// 在 hPath 中加入笔记本名 Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378

var boxIDs []string
for _, b := range blocks {
boxIDs = append(boxIDs, b.Box)
Expand Down Expand Up @@ -1121,6 +1123,8 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]b
if 1 > len(ret) {
ret = []*Block{}
}

filterSelfHPath(ret)
return
}

Expand Down

0 comments on commit 4a19605

Please sign in to comment.