mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
🐛 折叠标题移动到下方后触发状态异常并导致数据丢失 Fix https://github.com/siyuan-note/siyuan/issues/7163
This commit is contained in:
parent
2dec9f2434
commit
b3edfec60e
1 changed files with 14 additions and 10 deletions
|
|
@ -311,11 +311,8 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
|||
}
|
||||
}
|
||||
|
||||
for _, headingChild := range headingChildren {
|
||||
if headingChild.ID == targetNode.ID {
|
||||
// 不能将折叠标题移动到自己下方节点的前或后 https://github.com/siyuan-note/siyuan/issues/7163
|
||||
return
|
||||
}
|
||||
if isMovingFoldHeadingIntoSelf(targetNode, headingChildren) {
|
||||
return
|
||||
}
|
||||
|
||||
for i := len(headingChildren) - 1; -1 < i; i-- {
|
||||
|
|
@ -360,11 +357,8 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
|||
return &TxErr{code: TxErrCodeBlockNotFound, id: targetParentID}
|
||||
}
|
||||
|
||||
for _, headingChild := range headingChildren {
|
||||
if headingChild.ID == targetNode.ID {
|
||||
// 不能将折叠标题移动到自己下方节点的前或后 https://github.com/siyuan-note/siyuan/issues/7163
|
||||
return
|
||||
}
|
||||
if isMovingFoldHeadingIntoSelf(targetNode, headingChildren) {
|
||||
return
|
||||
}
|
||||
|
||||
processed := false
|
||||
|
|
@ -421,6 +415,16 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
|||
return
|
||||
}
|
||||
|
||||
func isMovingFoldHeadingIntoSelf(targetNode *ast.Node, headingChildren []*ast.Node) bool {
|
||||
for _, headingChild := range headingChildren {
|
||||
if headingChild.ID == targetNode.ID {
|
||||
// 不能将折叠标题移动到自己下方节点的前或后 https://github.com/siyuan-note/siyuan/issues/7163
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (tx *Transaction) doPrependInsert(operation *Operation) (ret *TxErr) {
|
||||
var err error
|
||||
block := treenode.GetBlockTree(operation.ParentID)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue