Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-10-04 18:16:57 +08:00
commit a87f096fb1
4 changed files with 21 additions and 22 deletions

View file

@ -254,13 +254,15 @@ func buildBacklink(refID string, refTree *parse.Tree, luteEngine *lute.Lute) (re
c = n.FirstChild.Next
}
for liFirstBlockSpan := c.FirstChild; nil != liFirstBlockSpan; liFirstBlockSpan = liFirstBlockSpan.Next {
if treenode.IsBlockRef(liFirstBlockSpan) {
continue
}
if "" != strings.TrimSpace(liFirstBlockSpan.Text()) {
expand = false
break
if c != n.LastChild { // 存在子列表
for liFirstBlockSpan := c.FirstChild; nil != liFirstBlockSpan; liFirstBlockSpan = liFirstBlockSpan.Next {
if treenode.IsBlockRef(liFirstBlockSpan) {
continue
}
if "" != strings.TrimSpace(liFirstBlockSpan.Text()) {
expand = false
break
}
}
}

View file

@ -106,7 +106,13 @@ func SwapBlockRef(refID, defID string, includeChildren bool) (err error) {
if nil != err {
return
}
defNode := treenode.GetNodeInTree(defTree, defID)
sameTree := defTree.ID == refTree.ID
var defNode *ast.Node
if !sameTree {
defNode = treenode.GetNodeInTree(defTree, defID)
} else {
defNode = treenode.GetNodeInTree(refTree, defID)
}
if nil == defNode {
return
}
@ -185,9 +191,11 @@ func SwapBlockRef(refID, defID string, includeChildren bool) (err error) {
if err = writeJSONQueue(refTree); nil != err {
return
}
treenode.ReindexBlockTree(defTree)
if err = writeJSONQueue(defTree); nil != err {
return
if !sameTree {
treenode.ReindexBlockTree(defTree)
if err = writeJSONQueue(defTree); nil != err {
return
}
}
WaitForWritingFiles()
util.ReloadUI()

View file

@ -997,8 +997,6 @@ func (tx *Transaction) begin() (err error) {
func (tx *Transaction) commit() (err error) {
for _, tree := range tx.trees {
go pushTreeStat(tree)
if err = writeJSONQueue(tree); nil != err {
return
}
@ -1009,11 +1007,6 @@ func (tx *Transaction) commit() (err error) {
return
}
func pushTreeStat(tree *parse.Tree) {
stat := treenode.StatTree(tree)
util.PushStatusBarCounter(stat)
}
func (tx *Transaction) rollback() {
tx.trees, tx.nodes = nil, nil
return

View file

@ -159,10 +159,6 @@ type BlockStatResult struct {
RefCount int `json:"refCount"`
}
func PushStatusBarCounter(stat *BlockStatResult) {
BroadcastByType("main", "statusbarCounter", 0, "", stat)
}
func ContextPushMsg(context map[string]interface{}, msg string) {
switch context[eventbus.CtxPushMsg].(int) {
case eventbus.CtxPushMsgToProgress: