mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Fix #29633
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { WorkspaceConfiguration } from 'vscode';
|
||||
import { WorkspaceConfiguration, WorkspaceConfiguration2 } from 'vscode';
|
||||
import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
|
||||
import { ExtHostConfigurationShape, MainThreadConfigurationShape } from './extHost.protocol';
|
||||
import { IConfigurationData, Configuration } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -24,6 +24,14 @@ function lookUp(tree: any, key: string) {
|
||||
}
|
||||
}
|
||||
|
||||
type ConfigurationInspect<T> = {
|
||||
key: string;
|
||||
defaultValue?: T;
|
||||
globalValue?: T;
|
||||
workspaceValue?: T;
|
||||
folderValue?: T;
|
||||
};
|
||||
|
||||
export class ExtHostConfiguration extends ExtHostConfigurationShape {
|
||||
|
||||
private readonly _onDidChangeConfiguration = new Emitter<void>();
|
||||
@@ -47,7 +55,15 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
|
||||
this._onDidChangeConfiguration.fire(undefined);
|
||||
}
|
||||
|
||||
getConfiguration(section?: string, resource?: URI): WorkspaceConfiguration {
|
||||
getConfiguration(section?: string): WorkspaceConfiguration {
|
||||
return this._getConfiguration(section, null, true);
|
||||
}
|
||||
|
||||
getConfiguration2(section?: string, resource?: URI): WorkspaceConfiguration2 {
|
||||
return this._getConfiguration(section, resource, false);
|
||||
}
|
||||
|
||||
private _getConfiguration(section: string, resource: URI, legacy: boolean): WorkspaceConfiguration {
|
||||
|
||||
const config = section
|
||||
? lookUp(this._configuration.getValue(null, { resource }), section)
|
||||
@@ -73,17 +89,20 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
|
||||
return this._proxy.$removeConfigurationOption(target, key);
|
||||
}
|
||||
},
|
||||
inspect: <T>(key: string): { key: string; defaultValue?: T; globalValue?: T; workspaceValue?: T, folderValue?: T } => {
|
||||
inspect: <T>(key: string): ConfigurationInspect<T> => {
|
||||
key = section ? `${section}.${key}` : key;
|
||||
const config = this._configuration.values()[key];
|
||||
const config = legacy ? this._configuration.lookupLegacy<T>(key) : this._configuration.lookup<T>(key, { resource });
|
||||
if (config) {
|
||||
return {
|
||||
const inspect: ConfigurationInspect<T> = {
|
||||
key,
|
||||
defaultValue: config.default,
|
||||
globalValue: config.user,
|
||||
workspaceValue: config.workspace,
|
||||
folderValue: config.folder
|
||||
};
|
||||
if (!legacy) {
|
||||
inspect.folderValue = config.folder;
|
||||
}
|
||||
return inspect;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user