diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 4ceee1bcfe4..4db9195fd09 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1305,7 +1305,7 @@ declare module 'vscode' { //#region Language specific settings: https://github.com/microsoft/vscode/issues/26707 - export type ConfigurationScope = Uri | TextDocument | WorkspaceFolder | { uri: Uri, languageId: string }; + export type ConfigurationScope = Uri | TextDocument | WorkspaceFolder | { uri?: Uri, languageId: string }; /** * An event describing the change in Configuration diff --git a/src/vs/workbench/api/common/extHostConfiguration.ts b/src/vs/workbench/api/common/extHostConfiguration.ts index 2319465e377..aeabbaed7c1 100644 --- a/src/vs/workbench/api/common/extHostConfiguration.ts +++ b/src/vs/workbench/api/common/extHostConfiguration.ts @@ -47,13 +47,6 @@ type ConfigurationInspect = { workspaceFolderLanguageValue?: T; }; -function isWorkspaceFolder(thing: any): thing is vscode.WorkspaceFolder { - return thing - && thing.uri instanceof URI - && (!thing.name || typeof thing.name === 'string') - && (!thing.index || typeof thing.index === 'number'); -} - function isUri(thing: any): thing is vscode.Uri { return thing instanceof URI; } @@ -61,19 +54,35 @@ function isUri(thing: any): thing is vscode.Uri { function isResourceLanguage(thing: any): thing is { uri: URI, languageId: string } { return thing && thing.uri instanceof URI - && (!thing.languageId || typeof thing.languageId === 'string'); + && (thing.languageId && typeof thing.languageId === 'string'); +} + +function isLanguage(thing: any): thing is { languageId: string } { + return thing + && !thing.uri + && (thing.languageId && typeof thing.languageId === 'string'); +} + +function isWorkspaceFolder(thing: any): thing is vscode.WorkspaceFolder { + return thing + && thing.uri instanceof URI + && (!thing.name || typeof thing.name === 'string') + && (!thing.index || typeof thing.index === 'number'); } function scopeToOverrides(scope: vscode.ConfigurationScope | undefined | null): IConfigurationOverrides | undefined { if (isUri(scope)) { return { resource: scope }; } - if (isWorkspaceFolder(scope)) { - return { resource: scope.uri }; - } if (isResourceLanguage(scope)) { return { resource: scope.uri, overrideIdentifier: scope.languageId }; } + if (isLanguage(scope)) { + return { overrideIdentifier: scope.languageId }; + } + if (isWorkspaceFolder(scope)) { + return { resource: scope.uri }; + } return undefined; }