Explorar el Código

:art: 改进提及和虚拟引用搜索分词 Fix https://github.com/siyuan-note/siyuan/issues/6176

Liang Ding hace 2 años
padre
commit
0b7c6a851e
Se han modificado 2 ficheros con 13 adiciones y 2 borrados
  1. 5 0
      kernel/model/backlink.go
  2. 8 2
      kernel/model/search.go

+ 5 - 0
kernel/model/backlink.go

@@ -791,10 +791,15 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink
 
 		text := textBuf.String()
 		text = strings.ToLower(text)
+		text = luteEngine.Space(text)
 		var contain bool
 		for _, mentionKeyword := range mentionKeywords {
 			parts := strings.Split(text, " ")
 			for _, part := range parts {
+				if "" == part {
+					continue
+				}
+
 				if gulu.Str.IsASCII(mentionKeyword) {
 					if part == mentionKeyword {
 						contain = true

+ 8 - 2
kernel/model/search.go

@@ -649,8 +649,14 @@ func markReplaceSpan(text string, keywords []string, replacementStart, replaceme
 
 		for _, k := range keywords {
 			if gulu.Str.IsASCII(k) {
-				if part == k {
-					parts[i] = replacementStart + k + replacementEnd
+				if gulu.Str.IsASCII(part) {
+					if part == k {
+						parts[i] = replacementStart + k + replacementEnd
+					}
+				} else {
+					if strings.Contains(part, k) {
+						parts[i] = strings.ReplaceAll(part, k, replacementStart+k+replacementEnd)
+					}
 				}
 			} else {
 				if strings.Contains(part, k) {