mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Improve block ref search ID extraction https://github.com/siyuan-note/siyuan/issues/10848
This commit is contained in:
parent
eae61fd4a7
commit
455f348e91
1 changed files with 17 additions and 2 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue