Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #229955 #229959

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions src/vs/platform/configuration/common/configurationModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export class ConfigurationModel implements IConfigurationModel {
}

export interface ConfigurationParseOptions {
skipUnregistered?: boolean;
scopes?: ConfigurationScope[];
skipRestricted?: boolean;
include?: string[];
Expand Down Expand Up @@ -428,14 +429,10 @@ export class ConfigurationModelParser {
restricted.push(...result.restricted);
} else {
const propertySchema = configurationProperties[key];
const scope = propertySchema ? typeof propertySchema.scope !== 'undefined' ? propertySchema.scope : ConfigurationScope.WINDOW : undefined;
if (propertySchema?.restricted) {
restricted.push(key);
}
if (!options.exclude?.includes(key) /* Check exclude */
&& (options.include?.includes(key) /* Check include */
|| ((scope === undefined || options.scopes === undefined || options.scopes.includes(scope)) /* Check scopes */
&& !(options.skipRestricted && propertySchema?.restricted)))) /* Check restricted */ {
if (this.shouldInclude(key, propertySchema, options)) {
raw[key] = properties[key];
} else {
hasExcludedProperties = true;
Expand All @@ -445,6 +442,31 @@ export class ConfigurationModelParser {
return { raw, restricted, hasExcludedProperties };
}

private shouldInclude(key: string, propertySchema: IConfigurationPropertySchema | undefined, options: ConfigurationParseOptions): boolean {
if (options.exclude?.includes(key)) {
return false;
}

if (options.include?.includes(key)) {
return true;
}

if (options.skipRestricted && propertySchema?.restricted) {
return false;
}

if (options.skipUnregistered && !propertySchema) {
return false;
}

const scope = propertySchema ? typeof propertySchema.scope !== 'undefined' ? propertySchema.scope : ConfigurationScope.WINDOW : undefined;
if (scope === undefined || options.scopes === undefined) {
return true;
}

return options.scopes.includes(scope);
}

private toOverrides(raw: any, conflictReporter: (message: string) => void): IOverrides[] {
const overrides: IOverrides[] = [];
for (const key of Object.keys(raw)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class ApplicationConfiguration extends UserSettings {
uriIdentityService: IUriIdentityService,
logService: ILogService,
) {
super(userDataProfilesService.defaultProfile.settingsResource, { scopes: [ConfigurationScope.APPLICATION] }, uriIdentityService.extUri, fileService, logService);
super(userDataProfilesService.defaultProfile.settingsResource, { scopes: [ConfigurationScope.APPLICATION], skipUnregistered: true }, uriIdentityService.extUri, fileService, logService);
this._register(this.onDidChange(() => this.reloadConfigurationScheduler.schedule()));
this.reloadConfigurationScheduler = this._register(new RunOnceScheduler(() => this.loadConfiguration().then(configurationModel => this._onDidChangeConfiguration.fire(configurationModel)), 50));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,12 @@ suite('WorkspaceConfigurationService - Profiles', () => {
assert.strictEqual(testObject.getValue('configurationService.profiles.applicationSetting3'), 'defaultProfile');
}));

test('non registering setting should not be read from default profile', () => runWithFakedTimers<void>({ useFakeTimers: true }, async () => {
await fileService.writeFile(instantiationService.get(IUserDataProfilesService).defaultProfile.settingsResource, VSBuffer.fromString('{ "configurationService.profiles.nonregistered": "defaultProfile" }'));
await testObject.reloadConfiguration();
assert.strictEqual(testObject.getValue('configurationService.profiles.nonregistered'), undefined);
}));

test('initialize with custom all profiles settings', () => runWithFakedTimers<void>({ useFakeTimers: true }, async () => {
await testObject.updateValue(APPLY_ALL_PROFILES_SETTING, ['configurationService.profiles.testSetting2'], ConfigurationTarget.USER_LOCAL);

Expand Down
Loading