Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve list item deletion https://github.com/siyuan-note/siyuan/issues/13617

Danielb493aaee2e8e
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index c5cbcbb319..2f4ab61143 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -792,9 +792,17 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
node.Unlink()
if nil != parent && ast.NodeListItem == parent.Type && nil == parent.FirstChild {
- // 保持空列表项
- node.FirstChild = nil
- parent.AppendChild(node)
+ needAppendEmptyListItem := true
+ for _, op := range tx.DoOperations {
+ if "insert" == op.Action && op.ParentID == parent.ID {
+ needAppendEmptyListItem = false
+ break
+ }
+ }
+
+ if needAppendEmptyListItem {
+ parent.AppendChild(treenode.NewParagraph(ast.NewNodeID()))
+ }
}
treenode.RemoveBlockTree(node.ID)