Skip to content

Commit 29759db

Browse files
committed
microsoft#26707 Make uri optional
1 parent ec21190 commit 29759db

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

src/vs/vscode.proposed.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ declare module 'vscode' {
13051305

13061306
//#region Language specific settings: https://github.com/microsoft/vscode/issues/26707
13071307

1308-
export type ConfigurationScope = Uri | TextDocument | WorkspaceFolder | { uri: Uri, languageId: string };
1308+
export type ConfigurationScope = Uri | TextDocument | WorkspaceFolder | { uri?: Uri, languageId: string };
13091309

13101310
/**
13111311
* An event describing the change in Configuration

src/vs/workbench/api/common/extHostConfiguration.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,42 @@ type ConfigurationInspect<T> = {
4747
workspaceFolderLanguageValue?: T;
4848
};
4949

50-
function isWorkspaceFolder(thing: any): thing is vscode.WorkspaceFolder {
50+
function isUri(thing: any): thing is vscode.Uri {
51+
return thing instanceof URI;
52+
}
53+
54+
function isResourceLanguage(thing: any): thing is { uri: URI, languageId: string } {
5155
return thing
5256
&& thing.uri instanceof URI
53-
&& (!thing.name || typeof thing.name === 'string')
54-
&& (!thing.index || typeof thing.index === 'number');
57+
&& (thing.languageId && typeof thing.languageId === 'string');
5558
}
5659

57-
function isUri(thing: any): thing is vscode.Uri {
58-
return thing instanceof URI;
60+
function isLanguage(thing: any): thing is { languageId: string } {
61+
return thing
62+
&& !thing.uri
63+
&& (thing.languageId && typeof thing.languageId === 'string');
5964
}
6065

61-
function isResourceLanguage(thing: any): thing is { uri: URI, languageId: string } {
66+
function isWorkspaceFolder(thing: any): thing is vscode.WorkspaceFolder {
6267
return thing
6368
&& thing.uri instanceof URI
64-
&& (!thing.languageId || typeof thing.languageId === 'string');
69+
&& (!thing.name || typeof thing.name === 'string')
70+
&& (!thing.index || typeof thing.index === 'number');
6571
}
6672

6773
function scopeToOverrides(scope: vscode.ConfigurationScope | undefined | null): IConfigurationOverrides | undefined {
6874
if (isUri(scope)) {
6975
return { resource: scope };
7076
}
71-
if (isWorkspaceFolder(scope)) {
72-
return { resource: scope.uri };
73-
}
7477
if (isResourceLanguage(scope)) {
7578
return { resource: scope.uri, overrideIdentifier: scope.languageId };
7679
}
80+
if (isLanguage(scope)) {
81+
return { overrideIdentifier: scope.languageId };
82+
}
83+
if (isWorkspaceFolder(scope)) {
84+
return { resource: scope.uri };
85+
}
7786
return undefined;
7887
}
7988

0 commit comments

Comments
 (0)