Skip to content

Commit a5248f3

Browse files
committed
microsoft#28538 Proposed API to read configuration in a multi root workspace
1 parent fbfe700 commit a5248f3

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/vs/vscode.proposed.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,15 @@ declare module 'vscode' {
353353
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
354354
*/
355355
export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
356+
357+
358+
export function getConfiguration2(section?: string, resource?: Uri): WorkspaceConfiguration2;
359+
}
360+
361+
export interface WorkspaceConfiguration2 extends WorkspaceConfiguration {
362+
363+
inspect<T>(section: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T, folderValue?: T } | undefined;
364+
356365
}
357366

358367
export namespace window {

src/vs/workbench/api/node/extHost.api.impl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,9 @@ export function createApiFactory(
429429
getConfiguration: (section?: string): vscode.WorkspaceConfiguration => {
430430
return extHostConfiguration.getConfiguration(section);
431431
},
432+
getConfiguration2: proposedApiFunction(extension, (section?: string, resource?: vscode.Uri): vscode.WorkspaceConfiguration => {
433+
return extHostConfiguration.getConfiguration(section, <URI>resource);
434+
}),
432435
registerTaskProvider: proposedApiFunction(extension, (type: string, provider: vscode.TaskProvider) => {
433436
return extHostTask.registerTaskProvider(extension, provider);
434437
})

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'use strict';
66

77
import { mixin } from 'vs/base/common/objects';
8+
import URI from 'vs/base/common/uri';
89
import Event, { Emitter } from 'vs/base/common/event';
910
import { WorkspaceConfiguration } from 'vscode';
1011
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
@@ -46,11 +47,11 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
4647
this._onDidChangeConfiguration.fire(undefined);
4748
}
4849

49-
getConfiguration(section?: string): WorkspaceConfiguration {
50+
getConfiguration(section?: string, resource?: URI): WorkspaceConfiguration {
5051

5152
const config = section
52-
? lookUp(this._configuration.getValue(), section)
53-
: this._configuration.getValue();
53+
? lookUp(this._configuration.getValue(null, { resource }), section)
54+
: this._configuration.getValue(null, { resource });
5455

5556
const result: WorkspaceConfiguration = {
5657
has(key: string): boolean {
@@ -72,15 +73,16 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
7273
return this._proxy.$removeConfigurationOption(target, key);
7374
}
7475
},
75-
inspect: <T>(key: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T } => {
76+
inspect: <T>(key: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T, folderValue?: T } => {
7677
key = section ? `${section}.${key}` : key;
7778
const config = this._configuration.values()[key];
7879
if (config) {
7980
return {
8081
key,
8182
defaultValue: config.default,
8283
globalValue: config.user,
83-
workspaceValue: config.workspace
84+
workspaceValue: config.workspace,
85+
folderValue: config.folder
8486
};
8587
}
8688
return undefined;

0 commit comments

Comments
 (0)