[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 <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
(cherry picked from commit a267ffff876d81fa1918e31d6aca7a79280022b5)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/284794
TryBot-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/config.ts b/src/config.ts
index 9203e7c..6e367b0 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -16,7 +16,7 @@
// 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 @@
if (section !== 'go' || this._workspaceIsTrusted) {
return cfg;
}
-
return new WrappedConfiguration(cfg);
}
@@ -103,7 +102,9 @@
// 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);