mirror of
https://github.com/Microsoft/vscode
synced 2024-10-04 10:27:46 +00:00
improve empty workspace detection in web (#155643)
* improve empty workspace detection in web fixes #155214 * fix order of eval, unit test failures
This commit is contained in:
parent
9440d5c6b5
commit
646345fba6
|
@ -15,7 +15,7 @@ import { IRemoteAuthorityResolverService, ResolverResult } from 'vs/platform/rem
|
|||
import { getRemoteAuthority } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { isVirtualResource } from 'vs/platform/workspace/common/virtualWorkspace';
|
||||
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
|
||||
import { ISingleFolderWorkspaceIdentifier, isSavedWorkspace, isSingleFolderWorkspaceIdentifier, IWorkspace, IWorkspaceContextService, IWorkspaceFolder, toWorkspaceIdentifier, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { ISingleFolderWorkspaceIdentifier, isSavedWorkspace, isSingleFolderWorkspaceIdentifier, isTemporaryWorkspace, IWorkspace, IWorkspaceContextService, IWorkspaceFolder, toWorkspaceIdentifier, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { WorkspaceTrustRequestOptions, IWorkspaceTrustManagementService, IWorkspaceTrustInfo, IWorkspaceTrustUriInfo, IWorkspaceTrustRequestService, IWorkspaceTrustTransitionParticipant, WorkspaceTrustUriResponse, IWorkspaceTrustEnablementService } from 'vs/platform/workspace/common/workspaceTrust';
|
||||
import { Memento, MementoObject } from 'vs/workbench/common/memento';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
@ -132,7 +132,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
|
|||
this._workspaceTrustInitializedPromiseResolve = resolve;
|
||||
});
|
||||
|
||||
this._storedTrustState = new WorkspaceTrustMemento(isWeb && this.workspaceService.getWorkbenchState() === WorkbenchState.EMPTY ? undefined : this.storageService);
|
||||
this._storedTrustState = new WorkspaceTrustMemento(isWeb && this.isEmptyWorkspace() ? undefined : this.storageService);
|
||||
this._trustTransitionManager = this._register(new WorkspaceTrustTransitionManager());
|
||||
|
||||
this._trustStateInfo = this.loadTrustInfo();
|
||||
|
@ -172,7 +172,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
|
|||
}
|
||||
|
||||
// Empty workspace - save initial state to memento
|
||||
if (this.workspaceService.getWorkbenchState() === WorkbenchState.EMPTY) {
|
||||
if (this.isEmptyWorkspace()) {
|
||||
this._workspaceTrustInitializedPromise.then(() => {
|
||||
if (this._storedTrustState.isEmptyWorkspaceTrusted === undefined) {
|
||||
this._storedTrustState.isEmptyWorkspaceTrusted = this.isWorkspaceTrusted();
|
||||
|
@ -307,7 +307,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
|
|||
}
|
||||
|
||||
// Empty workspace - use memento, open ediors, or user setting
|
||||
if (this.workspaceService.getWorkbenchState() === WorkbenchState.EMPTY) {
|
||||
if (this.isEmptyWorkspace()) {
|
||||
// Use memento if present
|
||||
if (this._storedTrustState.isEmptyWorkspaceTrusted !== undefined) {
|
||||
return this._storedTrustState.isEmptyWorkspaceTrusted;
|
||||
|
@ -426,6 +426,19 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
|
|||
}
|
||||
}
|
||||
|
||||
private isEmptyWorkspace(): boolean {
|
||||
if (this.workspaceService.getWorkbenchState() === WorkbenchState.EMPTY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const workspace = this.workspaceService.getWorkspace();
|
||||
if (workspace) {
|
||||
return isTemporaryWorkspace(this.workspaceService.getWorkspace()) && workspace.folders.length === 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private isTrustedVirtualResource(uri: URI): boolean {
|
||||
return isVirtualResource(uri) && uri.scheme !== 'vscode-vfs';
|
||||
}
|
||||
|
@ -451,7 +464,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
|
|||
}
|
||||
|
||||
// Empty workspace - save memento
|
||||
if (this.workspaceService.getWorkbenchState() === WorkbenchState.EMPTY) {
|
||||
if (this.isEmptyWorkspace()) {
|
||||
this._storedTrustState.isEmptyWorkspaceTrusted = value;
|
||||
}
|
||||
}
|
||||
|
@ -530,7 +543,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
|
|||
}
|
||||
|
||||
// Empty workspace
|
||||
if (this.workspaceService.getWorkbenchState() === WorkbenchState.EMPTY) {
|
||||
if (this.isEmptyWorkspace()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -577,7 +590,7 @@ export class WorkspaceTrustManagementService extends Disposable implements IWork
|
|||
|
||||
async setWorkspaceTrust(trusted: boolean): Promise<void> {
|
||||
// Empty workspace
|
||||
if (this.workspaceService.getWorkbenchState() === WorkbenchState.EMPTY) {
|
||||
if (this.isEmptyWorkspace()) {
|
||||
await this.updateWorkspaceTrust(trusted);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue