diff --git a/src/features/app/closeGuard.ts b/src/features/app/closeGuard.ts index 2a0b1915c..45ed7bf60 100644 --- a/src/features/app/closeGuard.ts +++ b/src/features/app/closeGuard.ts @@ -9,7 +9,7 @@ */ import { commands, isTauri, onIdeEvent, type Settings } from "@/platform/ipc"; import { t } from "@/platform/i18n"; -import { provideLeaveProjectGuard, useProject } from "@/platform/project"; +import { closeProject, provideLeaveProjectGuard, useProject } from "@/platform/project"; import { maybeEditorService, notifications } from "@/workbench/contributions"; import { ask, type Ask } from "@/workbench/messages"; @@ -99,6 +99,12 @@ async function onCloseRequested(deps: CloseDeps): Promise { try { const ctx = await commands.windowCloseContext(); const s = useProject.getState(); + // Closing the last project window closes its project and shows the welcome screen + // (to open another one); closing the welcome screen, or quitting, closes the window. + if (!ctx.quitting && ctx.windows <= 1 && s.project) { + if (await confirmLeave(deps)) await closeProject(); + return false; + } const ok = await decideClose( { quitting: ctx.quitting,