mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-25 09:46:10 +01:00
🐛 Unable to find-replace tag https://github.com/siyuan-note/siyuan/issues/14588
This commit is contained in:
parent
c3517f48bd
commit
59c479419b
1 changed files with 22 additions and 8 deletions
|
|
@ -554,25 +554,41 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
}
|
||||
|
||||
reloadTreeIDs = append(reloadTreeIDs, tree.ID)
|
||||
|
||||
if ast.NodeDocument == node.Type {
|
||||
if !replaceTypes["docTitle"] {
|
||||
continue
|
||||
}
|
||||
|
||||
title := node.IALAttr("title")
|
||||
tags := node.IALAttr("tags")
|
||||
if 0 == method {
|
||||
if strings.Contains(title, keyword) {
|
||||
docTitleReplacement := strings.ReplaceAll(replacement, "/", "")
|
||||
docTitleReplacement := strings.ReplaceAll(replacement, "/", "/")
|
||||
renameRootTitles[node.ID] = strings.ReplaceAll(title, keyword, docTitleReplacement)
|
||||
renameRoots = append(renameRoots, node)
|
||||
}
|
||||
|
||||
if strings.Contains(tags, keyword) {
|
||||
replacement = strings.TrimPrefix(replacement, "#")
|
||||
replacement = strings.TrimSuffix(replacement, "#")
|
||||
tags = strings.ReplaceAll(tags, keyword, replacement)
|
||||
node.SetIALAttr("tags", tags)
|
||||
ReloadTag()
|
||||
}
|
||||
} else if 3 == method {
|
||||
if nil != r && r.MatchString(title) {
|
||||
docTitleReplacement := strings.ReplaceAll(replacement, "/", "")
|
||||
docTitleReplacement := strings.ReplaceAll(replacement, "/", "/")
|
||||
renameRootTitles[node.ID] = r.ReplaceAllString(title, docTitleReplacement)
|
||||
renameRoots = append(renameRoots, node)
|
||||
}
|
||||
|
||||
if nil != r && r.MatchString(tags) {
|
||||
replacement = strings.TrimPrefix(replacement, "#")
|
||||
replacement = strings.TrimSuffix(replacement, "#")
|
||||
tags = r.ReplaceAllString(tags, replacement)
|
||||
node.SetIALAttr("tags", tags)
|
||||
ReloadTag()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var unlinks []*ast.Node
|
||||
|
|
@ -905,14 +921,12 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
for _, unlink := range unlinks {
|
||||
unlink.Unlink()
|
||||
}
|
||||
|
||||
if err = writeTreeUpsertQueue(tree); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err = writeTreeUpsertQueue(tree); err != nil {
|
||||
return
|
||||
}
|
||||
updateNodes[id] = node
|
||||
|
||||
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(206), i+1, len(ids)))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue