Skip to content

Commit

Permalink
[release] src/config: fix initConfig and WrappedConfiguration
Browse files Browse the repository at this point in the history
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 <[email protected]>
Run-TryBot: Hyang-Ah Hana Kim <[email protected]>
Reviewed-by: Suzy Mueller <[email protected]>
(cherry picked from commit a267fff)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/284794
TryBot-Result: kokoro <[email protected]>
  • Loading branch information
hyangah committed Jan 19, 2021
1 parent d0d360a commit e988b14
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -81,7 +81,6 @@ export class Configuration {
if (section !== 'go' || this._workspaceIsTrusted) {
return cfg;
}

return new WrappedConfiguration(cfg);
}

Expand All @@ -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);
Expand Down

0 comments on commit e988b14

Please sign in to comment.