From e988b144709e93387507d432fa4c14436dfe0e27 Mon Sep 17 00:00:00 2001 From: Hana Date: Tue, 19 Jan 2021 15:19:19 -0500 Subject: [PATCH] [release] src/config: fix initConfig and WrappedConfiguration workspaceIsTrusted is a function, not a variable. Make sure the properties to be overriden by WrappedConfiguration are what we want, by not copying them in the constructor. Change-Id: Ia88c31651005f0bb6c95e8316b955f4fcb63d8dc Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/284586 Trust: Hyang-Ah Hana Kim Run-TryBot: Hyang-Ah Hana Kim Reviewed-by: Suzy Mueller (cherry picked from commit a267ffff876d81fa1918e31d6aca7a79280022b5) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/284794 TryBot-Result: kokoro --- src/config.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/config.ts b/src/config.ts index 9203e7c35a..6e367b0b1f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -16,7 +16,7 @@ const SECURITY_SENSITIVE_CONFIG: string[] = [ // the user has to explicitly opt in to trust the workspace. export async function initConfig(ctx: vscode.ExtensionContext) { const isTrusted = getFromWorkspaceState(WORKSPACE_IS_TRUSTED_KEY, false); - if (isTrusted !== defaultConfig.workspaceIsTrusted) { + if (isTrusted !== defaultConfig.workspaceIsTrusted()) { defaultConfig.toggleWorkspaceIsTrusted(); } ctx.subscriptions.push( @@ -81,7 +81,6 @@ export class Configuration { if (section !== 'go' || this._workspaceIsTrusted) { return cfg; } - return new WrappedConfiguration(cfg); } @@ -103,7 +102,9 @@ class WrappedConfiguration implements vscode.WorkspaceConfiguration { // set getters for direct setting access (e.g. cfg.gopath), but don't overwrite _wrapped. const desc = Object.getOwnPropertyDescriptors(_wrapped); for (const prop in desc) { - if (typeof prop === 'string' && prop !== '_wrapped') { + // TODO(hyangah): find a better way to exclude WrappedConfiguration's members. + // These methods are defined by WrappedConfiguration. + if (typeof prop === 'string' && !['get', 'has', 'inspect', 'update', '_wrapped'].includes(prop)) { const d = desc[prop]; if (SECURITY_SENSITIVE_CONFIG.includes(prop)) { const inspect = this._wrapped.inspect(prop);