🎨 Improve document tree custom sorting stability when creating a notebook or doc https://github.com/siyuan-note/siyuan/issues/15716

This commit is contained in:
Daniel 2025-08-29 16:11:43 +08:00
parent c17a09d37e
commit 6c1156afc8
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 12 additions and 1 deletions

View file

@ -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
}

View file

@ -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)