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

This commit is contained in:
Daniel 2025-01-10 22:23:44 +08:00
parent 87c8db09a0
commit d7ebe561f0
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 17 additions and 8 deletions

View file

@ -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 用于重新加载属性视图。

View file

@ -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