Skip to content

Commit 16d3b65

Browse files
committed
🎨 Improve search for emojis in tags #15391
1 parent 211648b commit 16d3b65

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

kernel/model/search.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,9 +2213,12 @@ func getRefSearchIgnoreLines() (ret []string) {
22132213
func filterQueryInvisibleChars(query string) string {
22142214
query = strings.ReplaceAll(query, " ", "_@full_width_space@_")
22152215
query = strings.ReplaceAll(query, "\t", "_@tab@_")
2216+
query = strings.ReplaceAll(query, string(gulu.ZWJ), "__@ZWJ@__")
22162217
query = util.RemoveInvalid(query)
22172218
query = strings.ReplaceAll(query, "_@full_width_space@_", " ")
22182219
query = strings.ReplaceAll(query, "_@tab@_", "\t")
2220+
query = strings.ReplaceAll(query, "__@ZWJ@__", string(gulu.ZWJ))
2221+
query = strings.ReplaceAll(query, string(gulu.ZWJ)+"#", "#")
22192222
return query
22202223
}
22212224

kernel/sql/database.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,9 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
667667
return
668668
case ast.NodeTextMark:
669669
typ := treenode.TypeAbbr(n.Type.String()) + " " + n.TextMarkType
670-
text := n.Content()
670+
text := strings.TrimSuffix(n.Content(), string(gulu.ZWJ))
671671
markdown := treenode.ExportNodeStdMd(n, luteEngine)
672+
markdown = strings.ReplaceAll(markdown, string(gulu.ZWJ)+"#", "#")
672673
parentBlock := treenode.ParentBlock(n)
673674
span := &Span{
674675
ID: ast.NewNodeID(),
@@ -873,6 +874,11 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
873874
content = strings.ReplaceAll(content, editor.Zwsp, "")
874875
markdown = strings.ReplaceAll(markdown, editor.Zwsp, "")
875876

877+
// 剔除标签结尾处的零宽连字符 Improve search for emojis in tags https://github.com/siyuan-note/siyuan/issues/15391
878+
fcontent = strings.ReplaceAll(fcontent, string(gulu.ZWJ)+"#", "#")
879+
content = strings.ReplaceAll(content, string(gulu.ZWJ)+"#", "#")
880+
markdown = strings.ReplaceAll(markdown, string(gulu.ZWJ)+"#", "#")
881+
876882
block = &Block{
877883
ID: n.ID,
878884
ParentID: parentID,

0 commit comments

Comments
 (0)