diff --git a/packages/workspace/src/browser/workspace-frontend-contribution.ts b/packages/workspace/src/browser/workspace-frontend-contribution.ts index fe04646af3fd5..eff12355b91d3 100644 --- a/packages/workspace/src/browser/workspace-frontend-contribution.ts +++ b/packages/workspace/src/browser/workspace-frontend-contribution.ts @@ -63,9 +63,12 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi isEnabled: () => this.workspaceService.opened, execute: () => this.closeWorkspace() }); - commands.registerCommand(WorkspaceCommands.OPEN_RECENT_WORKSPACE, { - isEnabled: () => this.workspaceService.hasHistory, - execute: () => this.quickOpenWorkspace.select() + this.workspaceService.recentWorkspaces().then(({ length }) => { + if (!length) { + commands.registerCommand(WorkspaceCommands.OPEN_RECENT_WORKSPACE, { + execute: () => this.quickOpenWorkspace.select() + }); + } }); commands.registerCommand(WorkspaceCommands.SAVE_WORKSPACE_AS, { isEnabled: () => this.workspaceService.isMultiRootWorkspaceOpened, diff --git a/packages/workspace/src/browser/workspace-service.ts b/packages/workspace/src/browser/workspace-service.ts index 78189dae1ad44..ee7777f5557f0 100644 --- a/packages/workspace/src/browser/workspace-service.ts +++ b/packages/workspace/src/browser/workspace-service.ts @@ -46,8 +46,6 @@ export class WorkspaceService implements FrontendApplicationContribution { private _roots: FileStat[] = []; private deferredRoots = new Deferred(); - private hasWorkspace: boolean = false; - @inject(FileSystem) protected readonly fileSystem: FileSystem; @@ -193,17 +191,6 @@ export class WorkspaceService implements FrontendApplicationContribution { this.server.setMostRecentlyUsedWorkspace(this._workspace ? this._workspace.uri : ''); } - async onStart() { - const allWorkspace = await this.recentWorkspaces(); - if (allWorkspace.length > 0) { - this.hasWorkspace = true; - } - } - - get hasHistory(): boolean { - return this.hasWorkspace; - } - async recentWorkspaces(): Promise { return this.server.getRecentWorkspaces(); }