An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve block ref search ID extraction https://github.com/siyuan-note/siyuan/issues/10848
Daniel455f348e913b
diff --git a/kernel/model/search.go b/kernel/model/search.goindex b29ae1ab30..e1a93c31cd 100644--- a/kernel/model/search.go+++ b/kernel/model/search.go@@ -1045,8 +1045,8 @@ func removeLimitClause(stmt string) string {func fullTextSearchRefBlock(keyword string, beforeLen int, onlyDoc bool) (ret []*Block) {keyword = filterQueryInvisibleChars(keyword)- if ast.IsNodeIDPattern(keyword) {- ret, _, _ = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+keyword+"'", 36, 1, 32)+ if id := extractID(keyword); "" != id {+ ret, _, _ = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+id+"'", 36, 1, 32)return}@@ -1106,6 +1106,21 @@ func fullTextSearchRefBlock(keyword string, beforeLen int, onlyDoc bool) (ret []return}+func extractID(content string) (ret string) {+ if 22 > len(content) {+ return+ }++ // 从第一个字符开始循环,直到找到一个合法的 ID 为止+ for i := 0; i < len(content)-21; i++ {+ if ast.IsNodeIDPattern(content[i : i+22]) {+ ret = content[i : i+22]+ return+ }+ }+ return+}+func fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, orderBy string, beforeLen, page, pageSize int) (ret []*Block, matchedBlockCount, matchedRootCount int) {query = filterQueryInvisibleChars(query)if ast.IsNodeIDPattern(query) {