From 288eb24474ed21416c69d6ec366f22ef67189d8e Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 9 Oct 2023 17:30:19 +0800 Subject: [PATCH] :art: Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378 --- kernel/model/search.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/kernel/model/search.go b/kernel/model/search.go index cd82697bf2b..a8a672c5fa8 100644 --- a/kernel/model/search.go +++ b/kernel/model/search.go @@ -161,6 +161,9 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets if 1 > len(ret) { ret = []*Block{} } + + // 在 hPath 中加入笔记本名 Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378 + prependNotebookNameInHPath(ret) return } @@ -205,9 +208,25 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets newDoc = nil == treenode.GetBlockTreeRootByHPath(block.BoxID, p) } } + + // 在 hPath 中加入笔记本名 Show notebooks in hpath of block ref search list results https://github.com/siyuan-note/siyuan/issues/9378 + prependNotebookNameInHPath(ret) return } +func prependNotebookNameInHPath(blocks []*Block) { + var boxIDs []string + for _, b := range blocks { + boxIDs = append(boxIDs, b.Box) + } + boxIDs = gulu.Str.RemoveDuplicatedElem(boxIDs) + boxNames := Conf.BoxNames(boxIDs) + for _, b := range blocks { + name := boxNames[b.Box] + b.HPath = name + b.HPath + } +} + func FindReplace(keyword, replacement string, ids []string, paths, boxes []string, types map[string]bool, method, orderBy, groupBy int) (err error) { // method:0:文本,1:查询语法,2:SQL,3:正则表达式 if 1 == method || 2 == method {