Skip to content

Commit

Permalink
Change default scope for PreferenceService.set
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Grant <[email protected]>
  • Loading branch information
colin-grant-work committed Mar 10, 2021
1 parent bb17f71 commit 8be966b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/core/src/browser/preferences/preference-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export interface PreferenceService extends Disposable {
* @param value the new value of the preference.
* @param scope the scope for which the value shall be set, i.e. user, workspace etc.
* When the folder scope is specified a resourceUri must be provided.
* Defaults to folder scope if resourceUri is provided, user scope otherwise.
* @param resourceUri the uri of the resource for which the preference is stored. This used to store
* a potentially different value for the same preference for different resources, for example `files.encoding`.
*
Expand Down Expand Up @@ -401,10 +402,7 @@ export class PreferenceServiceImpl implements PreferenceService {
}

async set(preferenceName: string, value: any, scope: PreferenceScope | undefined, resourceUri?: string): Promise<void> {
const resolvedScope = scope !== undefined ? scope : (!resourceUri ? PreferenceScope.Workspace : PreferenceScope.Folder);
if (resolvedScope === PreferenceScope.User && this.configurations.isSectionName(preferenceName.split('.', 1)[0])) {
throw new Error(`Unable to write to User Settings because ${preferenceName} does not support for global scope.`);
}
const resolvedScope = scope ?? (resourceUri ? PreferenceScope.Folder : PreferenceScope.User);
if (resolvedScope === PreferenceScope.Folder && !resourceUri) {
throw new Error('Unable to write to Folder Settings because no resource is provided.');
}
Expand Down

0 comments on commit 8be966b

Please sign in to comment.