From 6ff917f48debb43f5aefd86c3767adeeb8a991d0 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 14 Mar 2024 09:46:54 +0800 Subject: [PATCH] :art: Open the last workspace by default https://github.com/siyuan-note/siyuan/issues/10570 --- kernel/model/conf.go | 12 ++++++++++++ kernel/util/working.go | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kernel/model/conf.go b/kernel/model/conf.go index c664da166..2ee3ffc74 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -587,6 +587,18 @@ func Close(force bool, execInstallPkg int) (exitCode int) { clearWorkspaceTemp() clearCorruptedNotebooks() clearPortJSON() + + // 将当前工作空间放到工作空间列表的最后一个 + // Open the last workspace by default https://github.com/siyuan-note/siyuan/issues/10570 + workspacePaths, err := util.ReadWorkspacePaths() + if nil != err { + logging.LogErrorf("read workspace paths failed: %s", err) + } else { + workspacePaths = gulu.Str.RemoveElem(workspacePaths, util.WorkspaceDir) + workspacePaths = append(workspacePaths, util.WorkspaceDir) + util.WriteWorkspacePaths(workspacePaths) + } + util.UnlockWorkspace() time.Sleep(500 * time.Millisecond) diff --git a/kernel/util/working.go b/kernel/util/working.go index 03caaf096..43dc0c82e 100644 --- a/kernel/util/working.go +++ b/kernel/util/working.go @@ -243,7 +243,6 @@ func initWorkspaceDir(workspaceArg string) { } else { workspacePaths, _ = ReadWorkspacePaths() if 0 < len(workspacePaths) { - // 取最后一个(也就是最近打开的)工作空间 WorkspaceDir = workspacePaths[len(workspacePaths)-1] } else { WorkspaceDir = defaultWorkspaceDir