Skip to content

Commit 1bd9cbc

Browse files
authored
sessions: change workbench state to worksapce and do not send workspace data to ext host (#298301)
1 parent df40d0e commit 1bd9cbc

File tree

7 files changed

+25
-3
lines changed

7 files changed

+25
-3
lines changed

src/vs/editor/contrib/snippet/test/browser/snippetVariables.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ suite('Snippet Variables Resolver', function () {
371371
getCompleteWorkspace = this._throw;
372372
getWorkspace(): IWorkspace { return workspace; }
373373
getWorkbenchState = this._throw;
374+
hasWorkspaceData = this._throw;
374375
getWorkspaceFolder = this._throw;
375376
isCurrentWorkspace = this._throw;
376377
isInsideWorkspace = this._throw;

src/vs/editor/standalone/browser/standaloneServices.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,10 @@ class StandaloneWorkspaceContextService implements IWorkspaceContextService {
852852
return WorkbenchState.EMPTY;
853853
}
854854

855+
public hasWorkspaceData(): boolean {
856+
return this.getWorkbenchState() !== WorkbenchState.EMPTY;
857+
}
858+
855859
public getWorkspaceFolder(resource: URI): IWorkspaceFolder | null {
856860
return resource && resource.scheme === StandaloneWorkspaceContextService.SCHEME ? this.workspace.folders[0] : null;
857861
}

src/vs/platform/workspace/common/workspace.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ export interface IWorkspaceContextService {
7474
* Returns if the provided resource is inside the workspace or not.
7575
*/
7676
isInsideWorkspace(resource: URI): boolean;
77+
78+
/**
79+
* Return `true` if the current workspace has data (e.g. folders or a workspace configuration) that can be sent to the extension host, otherwise `false`.
80+
*/
81+
hasWorkspaceData(): boolean;
7782
}
7883

7984
export interface IResolvedWorkspace extends IWorkspaceIdentifier, IBaseWorkspace {

src/vs/sessions/services/workspace/browser/workspaceContextService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ export class SessionsWorkspaceContextService extends Disposable implements IWork
4949
}
5050

5151
getWorkbenchState(): WorkbenchState {
52-
return WorkbenchState.EMPTY;
52+
return WorkbenchState.WORKSPACE;
53+
}
54+
55+
hasWorkspaceData(): boolean {
56+
return false;
5357
}
5458

5559
getWorkspaceFolder(resource: URI): IWorkspaceFolder | null {

src/vs/workbench/api/browser/mainThreadWorkspace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ILabelService } from '../../../platform/label/common/label.js';
1616
import { INotificationService } from '../../../platform/notification/common/notification.js';
1717
import { AuthInfo, Credentials, IRequestService } from '../../../platform/request/common/request.js';
1818
import { WorkspaceTrustRequestOptions, IWorkspaceTrustManagementService, IWorkspaceTrustRequestService, ResourceTrustRequestOptions } from '../../../platform/workspace/common/workspaceTrust.js';
19-
import { IWorkspace, IWorkspaceContextService, WorkbenchState, isUntitledWorkspace, WorkspaceFolder } from '../../../platform/workspace/common/workspace.js';
19+
import { IWorkspace, IWorkspaceContextService, isUntitledWorkspace, WorkspaceFolder } from '../../../platform/workspace/common/workspace.js';
2020
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
2121
import { checkGlobFileExists } from '../../services/extensions/common/workspaceContains.js';
2222
import { IFileQueryBuilderOptions, ITextQueryBuilderOptions, QueryBuilder } from '../../services/search/common/queryBuilder.js';
@@ -130,7 +130,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
130130
}
131131

132132
private getWorkspaceData(workspace: IWorkspace): IWorkspaceData | null {
133-
if (this._contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
133+
if (!this._contextService.hasWorkspaceData()) {
134134
return null;
135135
}
136136
return {

src/vs/workbench/services/configuration/browser/configurationService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ export class WorkspaceService extends Disposable implements IWorkbenchConfigurat
194194
return WorkbenchState.EMPTY;
195195
}
196196

197+
public hasWorkspaceData(): boolean {
198+
return this.getWorkbenchState() !== WorkbenchState.EMPTY;
199+
}
200+
197201
public getWorkspaceFolder(resource: URI): IWorkspaceFolder | null {
198202
return this.workspace.getFolder(resource);
199203
}

src/vs/workbench/test/common/workbenchTestServices.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ export class TestContextService implements IWorkspaceContextService {
120120
return WorkbenchState.EMPTY;
121121
}
122122

123+
hasWorkspaceData(): boolean {
124+
return this.getWorkbenchState() !== WorkbenchState.EMPTY;
125+
}
126+
123127
getCompleteWorkspace(): Promise<IWorkspace> {
124128
return Promise.resolve(this.getWorkspace());
125129
}

0 commit comments

Comments
 (0)