From 6c1156afc887919d7bbd8eb06ab0696e0eea58c1 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 29 Aug 2025 16:11:43 +0800 Subject: [PATCH] :art: Improve document tree custom sorting stability when creating a notebook or doc https://github.com/siyuan-note/siyuan/issues/15716 --- kernel/model/file.go | 6 +++++- kernel/model/mount.go | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kernel/model/file.go b/kernel/model/file.go index 51dbaf4e3..fb9b77265 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -1024,7 +1024,11 @@ func CreateDocByMd(boxID, p, title, md string, sorts []string) (tree *parse.Tree } FlushTxQueue() - ChangeFileTreeSort(box.ID, sorts) + if 0 < len(sorts) { + ChangeFileTreeSort(box.ID, sorts) + } else { + box.addMinSort(path.Dir(tree.Path), tree.ID) + } return } diff --git a/kernel/model/mount.go b/kernel/model/mount.go index 41eabccd1..232ba9376 100644 --- a/kernel/model/mount.go +++ b/kernel/model/mount.go @@ -50,6 +50,13 @@ func CreateBox(name string) (id string, err error) { createDocLock.Lock() defer createDocLock.Unlock() + boxes, _ := ListNotebooks() + for i, b := range boxes { + c := b.GetConf() + c.Sort = i + 1 + b.SaveConf(c) + } + id = ast.NewNodeID() boxLocalPath := filepath.Join(util.DataDir, id) err = os.MkdirAll(boxLocalPath, 0755)