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 c = n.FirstChild.Next
} }
for liFirstBlockSpan := c.FirstChild; nil != liFirstBlockSpan; liFirstBlockSpan = liFirstBlockSpan.Next { if c != n.LastChild { // 存在子列表
if treenode.IsBlockRef(liFirstBlockSpan) { for liFirstBlockSpan := c.FirstChild; nil != liFirstBlockSpan; liFirstBlockSpan = liFirstBlockSpan.Next {
continue if treenode.IsBlockRef(liFirstBlockSpan) {
} continue
if "" != strings.TrimSpace(liFirstBlockSpan.Text()) { }
expand = false if "" != strings.TrimSpace(liFirstBlockSpan.Text()) {
break expand = false
break
}
} }
} }

View File

@ -106,7 +106,13 @@ func SwapBlockRef(refID, defID string, includeChildren bool) (err error) {
if nil != err { if nil != err {
return 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 { if nil == defNode {
return return
} }
@ -185,9 +191,11 @@ func SwapBlockRef(refID, defID string, includeChildren bool) (err error) {
if err = writeJSONQueue(refTree); nil != err { if err = writeJSONQueue(refTree); nil != err {
return return
} }
treenode.ReindexBlockTree(defTree) if !sameTree {
if err = writeJSONQueue(defTree); nil != err { treenode.ReindexBlockTree(defTree)
return if err = writeJSONQueue(defTree); nil != err {
return
}
} }
WaitForWritingFiles() WaitForWritingFiles()
util.ReloadUI() util.ReloadUI()

View File

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

View File

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