Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve find-replace for database block key text updating https://github.com/siyuan-note/siyuan/issues/13746

Danield7ebe561f064
diff --git a/kernel/model/push_reload.go b/kernel/model/push_reload.go
index 5c58b66a5b..ca1d862209 100644
--- a/kernel/model/push_reload.go
+++ b/kernel/model/push_reload.go
@@ -17,9 +17,6 @@
package model
import (
- "github.com/88250/lute"
- "github.com/88250/lute/render"
- "github.com/siyuan-note/siyuan/kernel/filesys"
"os"
"path"
"path/filepath"
@@ -28,10 +25,13 @@ import (
"github.com/88250/go-humanize"
"github.com/88250/gulu"
+ "github.com/88250/lute"
"github.com/88250/lute/ast"
"github.com/88250/lute/parse"
+ "github.com/88250/lute/render"
"github.com/emirpasic/gods/sets/hashset"
"github.com/siyuan-note/siyuan/kernel/av"
+ "github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
@@ -238,6 +238,15 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees m
}
// 2. 更新属性视图主键内容
+ updateAttributeViewBlockText(updatedDefNodes)
+
+ // 3. 保存变更
+ for _, tree := range changedRefTree {
+ indexWriteTreeUpsertQueue(tree)
+ }
+}
+
+func updateAttributeViewBlockText(updatedDefNodes map[string]*ast.Node) {
var parents []*ast.Node
for _, updatedDefNode := range updatedDefNodes {
for parent := updatedDefNode.Parent; nil != parent && ast.NodeDocument != parent.Type; parent = parent.Parent {
@@ -287,11 +296,6 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees m
}
}
}
-
- // 3. 保存变更
- for _, tree := range changedRefTree {
- indexWriteTreeUpsertQueue(tree)
- }
}
// ReloadAttrView 用于重新加载属性视图。
diff --git a/kernel/model/search.go b/kernel/model/search.go
index 8fdd9296f3..f127222c17 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -536,6 +536,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
luteEngine := util.NewLute()
var reloadTreeIDs []string
+ updateNodes := map[string]*ast.Node{}
for i, id := range ids {
bt := treenode.GetBlockTree(id)
if nil == bt {
@@ -863,6 +864,8 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
}
}
+ updateNodes[id] = node
+
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(206), i+1, len(ids)))
}
@@ -880,6 +883,8 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
refreshProtyle(id)
}
+ updateAttributeViewBlockText(updateNodes)
+
sql.FlushQueue()
util.PushClearProgress()
return