瀏覽代碼

:bug: The keyboard element is highlighted incorrectly in backlink mentions Fix https://github.com/siyuan-note/siyuan/issues/8143

Liang Ding 2 年之前
父節點
當前提交
3d0b3c5ac9
共有 2 個文件被更改,包括 12 次插入0 次删除
  1. 8 0
      kernel/model/virutalref.go
  2. 4 0
      kernel/search/mark.go

+ 8 - 0
kernel/model/virutalref.go

@@ -232,6 +232,14 @@ func getVirtualRefKeywords(docName string) (ret []string) {
 
 
 func prepareMarkKeywords(keywords []string) (ret []string) {
 func prepareMarkKeywords(keywords []string) (ret []string) {
 	ret = gulu.Str.RemoveDuplicatedElem(keywords)
 	ret = gulu.Str.RemoveDuplicatedElem(keywords)
+	var tmp []string
+	for _, k := range ret {
+		if "" != k {
+			tmp = append(tmp, k)
+		}
+	}
+	ret = tmp
+
 	sort.SliceStable(ret, func(i, j int) bool {
 	sort.SliceStable(ret, func(i, j int) bool {
 		return len(ret[i]) > len(ret[j])
 		return len(ret[i]) > len(ret[j])
 	})
 	})

+ 4 - 0
kernel/search/mark.go

@@ -88,6 +88,10 @@ func EncloseHighlighting(text string, keywords []string, openMark, closeMark str
 	}
 	}
 	re := ic + "("
 	re := ic + "("
 	for i, k := range keywords {
 	for i, k := range keywords {
+		if "" == k {
+			continue
+		}
+
 		wordBoundary := false
 		wordBoundary := false
 		if splitWords {
 		if splitWords {
 			wordBoundary = lex.IsASCIILetterNums(gulu.Str.ToBytes(k)) // Improve virtual reference split words https://github.com/siyuan-note/siyuan/issues/7833
 			wordBoundary = lex.IsASCIILetterNums(gulu.Str.ToBytes(k)) // Improve virtual reference split words https://github.com/siyuan-note/siyuan/issues/7833