An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: 查找替换文档名以后动态引用锚文本未跟随改变 Fix https://github.com/siyuan-note/siyuan/issues/5175
Liang Dingdcbcf7f3a7e3
diff --git a/kernel/model/search.go b/kernel/model/search.goindex 459c6974f4..cd777301e9 100644--- a/kernel/model/search.go+++ b/kernel/model/search.go@@ -133,6 +133,8 @@ func FindReplace(keyword, replacement string, ids []string) (err error) {}ids = util.RemoveDuplicatedElem(ids)+ var renameRoots []*ast.Node+ renameRootTitles := map[string]string{}for _, id := range ids {var tree *parse.Treetree, err = loadTreeByBlockID(id)@@ -154,7 +156,8 @@ func FindReplace(keyword, replacement string, ids []string) (err error) {case ast.NodeDocument:title := n.IALAttr("title")if strings.Contains(title, keyword) {- n.SetIALAttr("title", strings.ReplaceAll(title, keyword, replacement))+ renameRootTitles[n.ID] = strings.ReplaceAll(title, keyword, replacement)+ renameRoots = append(renameRoots, n)}case ast.NodeText, ast.NodeLinkText, ast.NodeLinkTitle, ast.NodeCodeSpanContent, ast.NodeCodeBlockCode, ast.NodeInlineMathContent, ast.NodeMathBlockContent:if bytes.Contains(n.Tokens, []byte(keyword)) {@@ -169,6 +172,11 @@ func FindReplace(keyword, replacement string, ids []string) (err error) {}}+ for _, renameRoot := range renameRoots {+ newTitle := renameRootTitles[renameRoot.ID]+ RenameDoc(renameRoot.Box, renameRoot.Path, newTitle)+ }+WaitForWritingFiles()if 1 < len(ids) {go func() {