mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
Boolean Trust State (#121141)
* move to boolean-based trust state * update api based on feedback
This commit is contained in:
@@ -32,7 +32,7 @@ export class TypeScriptVersionManager extends Disposable {
|
||||
this._currentVersion = this.versionProvider.defaultVersion;
|
||||
|
||||
if (this.useWorkspaceTsdkSetting) {
|
||||
if (this.isWorkspaceTrusted) {
|
||||
if (vscode.workspace.isTrusted) {
|
||||
const localVersion = this.versionProvider.localVersion;
|
||||
if (localVersion) {
|
||||
this._currentVersion = localVersion;
|
||||
@@ -40,8 +40,8 @@ export class TypeScriptVersionManager extends Disposable {
|
||||
} else {
|
||||
setImmediate(() => {
|
||||
vscode.workspace.requestWorkspaceTrust({ modal: false })
|
||||
.then(trustState => {
|
||||
if (trustState === vscode.WorkspaceTrustState.Trusted && this.versionProvider.localVersion) {
|
||||
.then(trusted => {
|
||||
if (trusted && this.versionProvider.localVersion) {
|
||||
this.updateActiveVersion(this.versionProvider.localVersion);
|
||||
} else {
|
||||
this.updateActiveVersion(this.versionProvider.defaultVersion);
|
||||
@@ -99,7 +99,7 @@ export class TypeScriptVersionManager extends Disposable {
|
||||
private getBundledPickItem(): QuickPickItem {
|
||||
const bundledVersion = this.versionProvider.defaultVersion;
|
||||
return {
|
||||
label: (!this.useWorkspaceTsdkSetting || !this.isWorkspaceTrusted
|
||||
label: (!this.useWorkspaceTsdkSetting || !vscode.workspace.isTrusted
|
||||
? '• '
|
||||
: '') + localize('useVSCodeVersionOption', "Use VS Code's Version"),
|
||||
description: bundledVersion.displayName,
|
||||
@@ -114,14 +114,14 @@ export class TypeScriptVersionManager extends Disposable {
|
||||
private getLocalPickItems(): QuickPickItem[] {
|
||||
return this.versionProvider.localVersions.map(version => {
|
||||
return {
|
||||
label: (this.useWorkspaceTsdkSetting && this.isWorkspaceTrusted && this.currentVersion.eq(version)
|
||||
label: (this.useWorkspaceTsdkSetting && vscode.workspace.isTrusted && this.currentVersion.eq(version)
|
||||
? '• '
|
||||
: '') + localize('useWorkspaceVersionOption', "Use Workspace Version"),
|
||||
description: version.displayName,
|
||||
detail: version.pathLabel,
|
||||
run: async () => {
|
||||
const trustState = await vscode.workspace.requestWorkspaceTrust();
|
||||
if (trustState === vscode.WorkspaceTrustState.Trusted) {
|
||||
const trusted = await vscode.workspace.requestWorkspaceTrust({ modal: true });
|
||||
if (trusted) {
|
||||
await this.workspaceState.update(useWorkspaceTsdkStorageKey, true);
|
||||
const tsConfig = vscode.workspace.getConfiguration('typescript');
|
||||
await tsConfig.update('tsdk', version.pathLabel, false);
|
||||
@@ -165,10 +165,6 @@ export class TypeScriptVersionManager extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private get isWorkspaceTrusted(): boolean {
|
||||
return vscode.workspace.trustState === vscode.WorkspaceTrustState.Trusted;
|
||||
}
|
||||
|
||||
private get useWorkspaceTsdkSetting(): boolean {
|
||||
return this.workspaceState.get<boolean>(useWorkspaceTsdkStorageKey, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user