From 4e0aa60ebffcbcf21a9e6b0dc648bf31931b280f Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 8 Sep 2024 23:51:26 +0800 Subject: [PATCH] :art: The interface will no longer be refreshed after find-replace https://github.com/siyuan-note/siyuan/issues/11844 --- kernel/model/search.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/kernel/model/search.go b/kernel/model/search.go index ed0687691..acd44ff8d 100644 --- a/kernel/model/search.go +++ b/kernel/model/search.go @@ -519,6 +519,8 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids } indexHistoryDir(filepath.Base(historyDir), util.NewLute()) + luteEngine := util.NewLute() + var reloadTreeIDs []string for i, id := range ids { bt := treenode.GetBlockTree(id) if nil == bt { @@ -535,6 +537,8 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids continue } + reloadTreeIDs = append(reloadTreeIDs, tree.ID) + if ast.NodeDocument == node.Type { if !replaceTypes["docTitle"] { continue @@ -555,7 +559,6 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids } } } else { - luteEngine := util.NewLute() var unlinks []*ast.Node ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus { if !entering { @@ -789,9 +792,13 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids } WaitForWritingFiles() - if 0 < len(ids) { - task.AppendAsyncTaskWithDelay(task.ReloadUI, 500*time.Millisecond, util.ReloadUI) + + reloadTreeIDs = gulu.Str.RemoveDuplicatedElem(reloadTreeIDs) + for _, id := range reloadTreeIDs { + util.PushProtyleReload(id) } + + util.PushClearProgress() return }