Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

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

Liang Ding3d0b3c5ac91d
diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go
index 5c1c8698c5..29a893e527 100644
--- a/kernel/model/virutalref.go
+++ b/kernel/model/virutalref.go
@@ -232,6 +232,14 @@ func getVirtualRefKeywords(docName string) (ret []string) {
func prepareMarkKeywords(keywords []string) (ret []string) {
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 {
return len(ret[i]) > len(ret[j])
})
diff --git a/kernel/search/mark.go b/kernel/search/mark.go
index 5e04985649..a9f0c5a004 100644
--- a/kernel/search/mark.go
+++ b/kernel/search/mark.go
@@ -88,6 +88,10 @@ func EncloseHighlighting(text string, keywords []string, openMark, closeMark str
}
re := ic + "("
for i, k := range keywords {
+ if "" == k {
+ continue
+ }
+
wordBoundary := false
if splitWords {
wordBoundary = lex.IsASCIILetterNums(gulu.Str.ToBytes(k)) // Improve virtual reference split words https://github.com/siyuan-note/siyuan/issues/7833