Skip to content

Commit

Permalink
workspace: add workbenchState context key
Browse files Browse the repository at this point in the history
The commit adds support for the `workbenchState` context key, which
declares if there is no workspace (empty), a folder, or a workspace
(multi-root) opened.

Signed-off-by: vince-fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto committed Dec 17, 2021
1 parent 390674c commit 89f6897
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,16 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi
const updateWorkspaceStateKey = () => workspaceStateKey.set(this.updateWorkspaceStateKey());
updateWorkspaceStateKey();

const workbenchStateKey = this.contextKeyService.createKey<WorkspaceState>('workbenchState', 'empty');
const updateWorkbenchStateKey = () => workbenchStateKey.set(this.updateWorkbenchStateKey());
updateWorkbenchStateKey();

this.updateStyles();
this.workspaceService.onWorkspaceChanged(() => {
this.updateEncodingOverrides();
updateWorkspaceFolderCountKey();
updateWorkspaceStateKey();
updateWorkbenchStateKey();
this.updateStyles();
});
}
Expand Down Expand Up @@ -495,8 +500,16 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi
}

protected updateWorkspaceStateKey(): WorkspaceState {
return this.doUpdateWorkspaceState();
}

protected updateWorkbenchStateKey(): WorkspaceState {
return this.doUpdateWorkspaceState();
}

protected doUpdateWorkspaceState(): WorkspaceState {
if (this.workspaceService.opened) {
return this.workspaceService.isMultiRootWorkspaceOpened ? 'folder' : 'workspace';
return this.workspaceService.isMultiRootWorkspaceOpened ? 'workspace' : 'folder';
}
return 'empty';
}
Expand Down

0 comments on commit 89f6897

Please sign in to comment.