mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Simplify document block paths in search results https://github.com/siyuan-note/siyuan/issues/13364
This commit is contained in:
parent
a1c21e9261
commit
4a1960516f
1 changed files with 8 additions and 4 deletions
|
|
@ -360,8 +360,8 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets,
|
||||||
ret = []*Block{}
|
ret = []*Block{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在 hPath 中加入笔记本名 Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378
|
|
||||||
prependNotebookNameInHPath(ret)
|
prependNotebookNameInHPath(ret)
|
||||||
|
filterSelfHPath(ret)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -423,15 +423,15 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets,
|
||||||
newDoc = true
|
newDoc = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在 hPath 中加入笔记本名 Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378
|
|
||||||
prependNotebookNameInHPath(ret)
|
prependNotebookNameInHPath(ret)
|
||||||
// 简化块引搜索列表中的文档块路径 Simplify document block paths in block ref search list https://github.com/siyuan-note/siyuan/issues/13364
|
|
||||||
// 文档块不显示自己的路径(最后一层)
|
|
||||||
filterSelfHPath(ret)
|
filterSelfHPath(ret)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func filterSelfHPath(blocks []*Block) {
|
func filterSelfHPath(blocks []*Block) {
|
||||||
|
// 简化搜索结果列表中的文档块路径 Simplify document block paths in search results https://github.com/siyuan-note/siyuan/issues/13364
|
||||||
|
// 文档块不显示自己的路径(最后一层)
|
||||||
|
|
||||||
for _, b := range blocks {
|
for _, b := range blocks {
|
||||||
if b.IsDoc() {
|
if b.IsDoc() {
|
||||||
b.HPath = strings.TrimSuffix(b.HPath, path.Base(b.HPath))
|
b.HPath = strings.TrimSuffix(b.HPath, path.Base(b.HPath))
|
||||||
|
|
@ -440,6 +440,8 @@ func filterSelfHPath(blocks []*Block) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func prependNotebookNameInHPath(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
|
var boxIDs []string
|
||||||
for _, b := range blocks {
|
for _, b := range blocks {
|
||||||
boxIDs = append(boxIDs, b.Box)
|
boxIDs = append(boxIDs, b.Box)
|
||||||
|
|
@ -1121,6 +1123,8 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]b
|
||||||
if 1 > len(ret) {
|
if 1 > len(ret) {
|
||||||
ret = []*Block{}
|
ret = []*Block{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filterSelfHPath(ret)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue