Skip to content

Commit

Permalink
🎨 Search preview area supports memo positioning #13465
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 15, 2024
1 parent c5a1a36 commit 0a87b9a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion kernel/model/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
}
}

existKeywords := 0 < len(keywords)
for _, n := range nodes {
var unlinks []*ast.Node
ast.Walk(n, func(n *ast.Node, entering bool) ast.WalkStatus {
Expand Down Expand Up @@ -679,7 +680,7 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
}
}

if highlight && 0 < len(keywords) {
if highlight && existKeywords {
hitBlock := false
for p := n.Parent; nil != p; p = p.Parent {
if p.ID == id {
Expand All @@ -702,6 +703,16 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
}
}

if existKeywords && id == n.ID {
inlines := n.ChildrenByType(ast.NodeTextMark)
for _, inline := range inlines {
if inline.IsTextMarkType("inline-memo") && util.ContainsSubStr(inline.TextMarkInlineMemoContent, keywords) {
// 支持行级备注搜索定位 https://github.com/siyuan-note/siyuan/issues/13465
keywords = append(keywords, inline.TextMarkTextContent)
}
}
}

if processVirtualRef(n, &unlinks, virtualBlockRefKeywords, refCount, luteEngine) {
return ast.WalkContinue
}
Expand All @@ -726,6 +737,7 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
keyword = strings.TrimSuffix(keyword, "#")
keywords[i] = keyword
}
keywords = gulu.Str.RemoveDuplicatedElem(keywords)

go setRecentDocByTree(tree)
return
Expand Down

0 comments on commit 0a87b9a

Please sign in to comment.