Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-12-31 11:32:51 +08:00
parent bb4d95ffa0
commit 156a28f27d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 49 additions and 14 deletions

View file

@ -276,14 +276,25 @@ func refreshDynamicRefText(updatedDefNode *ast.Node, updatedTree *parse.Tree) {
// refreshDynamicRefTexts 用于批量刷新块引用的动态锚文本。
// 该实现依赖了数据库缓存,导致外部调用时可能需要阻塞等待数据库写入后才能获取到 refs
func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees map[string]*parse.Tree) {
func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees map[string]*parse.Tree) (changedRootIDs []string) {
for t := range updatedTrees {
changedRootIDs = append(changedRootIDs, t)
}
for i := 0; i < 7; i++ {
updatedRefNodes, updatedRefTrees := refreshDynamicRefTexts0(updatedDefNodes, updatedTrees)
if 1 > len(updatedRefNodes) {
break
}
updatedDefNodes, updatedTrees = updatedRefNodes, updatedRefTrees
for t := range updatedTrees {
changedRootIDs = append(changedRootIDs, t)
}
}
changedRootIDs = gulu.Str.RemoveDuplicatedElem(changedRootIDs)
return
}
func refreshDynamicRefTexts0(updatedDefNodes map[string]*ast.Node, updatedTrees map[string]*parse.Tree) (updatedRefNodes map[string]*ast.Node, updatedRefTrees map[string]*parse.Tree) {