Skip to content

Commit 7b9a74e

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents b9eeaa1 + e3cce8b commit 7b9a74e

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

kernel/av/value.go

+4
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ func (value *Value) IsEdited() bool {
221221
}
222222

223223
func (value *Value) IsEmpty() bool {
224+
if nil == value {
225+
return true
226+
}
227+
224228
switch value.Type {
225229
case KeyTypeBlock:
226230
if nil == value.Block {

kernel/filesys/tree.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,6 @@ func LoadTrees(ids []string) (ret map[string]*parse.Tree) {
7272
return
7373
}
7474

75-
func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {
76-
filePath := filepath.Join(util.DataDir, boxID, p)
77-
data, err := filelock.ReadFile(filePath)
78-
if err != nil {
79-
logging.LogErrorf("load tree [%s] failed: %s", p, err)
80-
return
81-
}
82-
83-
ret, err = LoadTreeByData(data, boxID, p, luteEngine)
84-
return
85-
}
86-
8775
func batchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) (ret []*parse.Tree, errs []error) {
8876
waitGroup := sync.WaitGroup{}
8977
lock := sync.Mutex{}
@@ -119,6 +107,18 @@ func batchLoadTrees(boxIDs, paths []string, luteEngine *lute.Lute) (ret []*parse
119107
return
120108
}
121109

110+
func LoadTree(boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {
111+
filePath := filepath.Join(util.DataDir, boxID, p)
112+
data, err := filelock.ReadFile(filePath)
113+
if err != nil {
114+
logging.LogErrorf("load tree [%s] failed: %s", p, err)
115+
return
116+
}
117+
118+
ret, err = LoadTreeByData(data, boxID, p, luteEngine)
119+
return
120+
}
121+
122122
func LoadTreeByData(data []byte, boxID, p string, luteEngine *lute.Lute) (ret *parse.Tree, err error) {
123123
ret = parseJSON2Tree(boxID, p, data, luteEngine)
124124
if nil == ret {

kernel/model/backlink.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func buildBacklink(refID string, refTree *parse.Tree, keywords []string, highlig
230230
}
231231

232232
// 反链面板中显示块引用计数 Display reference counts in the backlink panel https://github.com/siyuan-note/siyuan/issues/13618
233-
fillBlockRefCount(renderNodes, 1)
233+
fillBlockRefCount(renderNodes)
234234

235235
dom := renderBlockDOMByNodes(renderNodes, luteEngine)
236236
var blockPaths []*BlockPath

kernel/model/block.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, heading
900900
}
901901

902902
// 嵌入块查询结果中显示块引用计数 https://github.com/siyuan-note/siyuan/issues/7191
903-
fillBlockRefCount(nodes, 0)
903+
fillBlockRefCount(nodes)
904904

905905
luteEngine := NewLute()
906906
luteEngine.RenderOptions.ProtyleContenteditable = false // 不可编辑

kernel/model/render.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func renderBlockText(node *ast.Node, excludeTypes []string, removeLineBreak bool
144144
return
145145
}
146146

147-
func fillBlockRefCount(nodes []*ast.Node, minRefCount int) {
147+
func fillBlockRefCount(nodes []*ast.Node) {
148148
var defIDs []string
149149
for _, n := range nodes {
150150
ast.Walk(n, func(n *ast.Node, entering bool) ast.WalkStatus {
@@ -166,7 +166,7 @@ func fillBlockRefCount(nodes []*ast.Node, minRefCount int) {
166166
return ast.WalkContinue
167167
}
168168

169-
if cnt := refCount[n.ID]; minRefCount < cnt {
169+
if cnt := refCount[n.ID]; 0 < cnt {
170170
n.SetIALAttr("refcount", strconv.Itoa(cnt))
171171
}
172172
return ast.WalkContinue

0 commit comments

Comments
 (0)