From 11fabe83adf20309b9be8e09bd1b3c61e83d48d6 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 10 Jan 2023 23:36:54 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=8F=8D=E9=93=BE=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=BF=87=E6=BB=A4=E5=85=B3=E9=94=AE=E5=AD=97?= =?UTF-8?q?=E9=AB=98=E4=BA=AE=20Fix=20https://github.com/siyuan-note/siyua?= =?UTF-8?q?n/issues/7028?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/backlink.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go index 2fd61ce5c..5272bf8e9 100644 --- a/kernel/model/backlink.go +++ b/kernel/model/backlink.go @@ -69,6 +69,7 @@ type Backlink struct { } func GetBackmentionDoc(defID, refTreeID, keyword string) (ret []*Backlink) { + keyword = strings.TrimSpace(keyword) ret = []*Backlink{} beforeLen := 12 sqlBlock := sql.GetBlock(defID) @@ -90,6 +91,11 @@ func GetBackmentionDoc(defID, refTreeID, keyword string) (ret []*Backlink) { mentions = append(mentions, mention) } } + + if "" != keyword { + mentionKeywords = append(mentionKeywords, keyword) + } + mentionKeywords = gulu.Str.RemoveDuplicatedElem(mentionKeywords) for _, mention := range mentions { refTree := treeCache[mention.RootID] if nil == refTree {