mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
Fix #75109
This commit is contained in:
parent
eabd2c51a4
commit
0d0e4dfe40
|
@ -98,7 +98,7 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
|
|||
disposables.push(logService);
|
||||
logService.info('main', JSON.stringify(configuration));
|
||||
|
||||
const configurationService = new ConfigurationService(environmentService.settingsResource.path);
|
||||
const configurationService = new ConfigurationService(environmentService.settingsResource);
|
||||
disposables.push(configurationService);
|
||||
await configurationService.initialize();
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ class CodeMain {
|
|||
process.once('exit', () => logService.dispose());
|
||||
services.set(ILogService, logService);
|
||||
|
||||
services.set(IConfigurationService, new ConfigurationService(environmentService.settingsResource.path));
|
||||
services.set(IConfigurationService, new ConfigurationService(environmentService.settingsResource));
|
||||
services.set(ILifecycleService, new SyncDescriptor(LifecycleService));
|
||||
services.set(IStateService, new SyncDescriptor(StateService));
|
||||
services.set(IRequestService, new SyncDescriptor(RequestService));
|
||||
|
|
|
@ -285,7 +285,7 @@ export async function main(argv: ParsedArgs): Promise<void> {
|
|||
|
||||
await Promise.all([environmentService.appSettingsHome, environmentService.extensionsPath].map(p => mkdirp(p)));
|
||||
|
||||
const configurationService = new ConfigurationService(environmentService.settingsResource.path);
|
||||
const configurationService = new ConfigurationService(environmentService.settingsResource);
|
||||
await configurationService.initialize();
|
||||
|
||||
services.set(IEnvironmentService, environmentService);
|
||||
|
|
|
@ -12,6 +12,8 @@ import { Event, Emitter } from 'vs/base/common/event';
|
|||
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { ConfigWatcher } from 'vs/base/node/config';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
export class ConfigurationService extends Disposable implements IConfigurationService, IDisposable {
|
||||
|
||||
|
@ -24,7 +26,7 @@ export class ConfigurationService extends Disposable implements IConfigurationSe
|
|||
readonly onDidChangeConfiguration: Event<IConfigurationChangeEvent> = this._onDidChangeConfiguration.event;
|
||||
|
||||
constructor(
|
||||
private readonly configurationPath: string
|
||||
private readonly settingsResource: URI
|
||||
) {
|
||||
super();
|
||||
this.configuration = new Configuration(new DefaultConfigurationModel(), new ConfigurationModel());
|
||||
|
@ -36,10 +38,13 @@ export class ConfigurationService extends Disposable implements IConfigurationSe
|
|||
this.userConfigModelWatcher.dispose();
|
||||
}
|
||||
|
||||
if (this.settingsResource.scheme !== Schemas.file) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return new Promise<void>((c, e) => {
|
||||
this.userConfigModelWatcher = this._register(new ConfigWatcher(this.configurationPath, {
|
||||
changeBufferDelay: 300, onError: error => onUnexpectedError(error), defaultConfig: new ConfigurationModelParser(this.configurationPath), parse: (content: string, parseErrors: any[]) => {
|
||||
const userConfigModelParser = new ConfigurationModelParser(this.configurationPath);
|
||||
this.userConfigModelWatcher = this._register(new ConfigWatcher(this.settingsResource.fsPath, {
|
||||
changeBufferDelay: 300, onError: error => onUnexpectedError(error), defaultConfig: new ConfigurationModelParser(this.settingsResource.fsPath), parse: (content: string, parseErrors: any[]) => {
|
||||
const userConfigModelParser = new ConfigurationModelParser(this.settingsResource.fsPath);
|
||||
userConfigModelParser.parseContent(content);
|
||||
parseErrors = [...userConfigModelParser.errors];
|
||||
return userConfigModelParser;
|
||||
|
|
|
@ -13,6 +13,7 @@ import { ConfigurationService } from 'vs/platform/configuration/node/configurati
|
|||
import * as uuid from 'vs/base/common/uuid';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { testFile } from 'vs/base/test/node/utils';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
suite('ConfigurationService - Node', () => {
|
||||
|
||||
|
@ -20,7 +21,7 @@ suite('ConfigurationService - Node', () => {
|
|||
const res = await testFile('config', 'config.json');
|
||||
fs.writeFileSync(res.testFile, '{ "foo": "bar" }');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
await service.initialize();
|
||||
const config = service.getValue<{
|
||||
foo: string;
|
||||
|
@ -38,7 +39,7 @@ suite('ConfigurationService - Node', () => {
|
|||
|
||||
fs.writeFileSync(res.testFile, '{ "testworkbench.editor.tabs": true }');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
await service.initialize();
|
||||
const config = service.getValue<{
|
||||
testworkbench: {
|
||||
|
@ -61,7 +62,7 @@ suite('ConfigurationService - Node', () => {
|
|||
|
||||
fs.writeFileSync(res.testFile, ',,,,');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
await service.initialize();
|
||||
const config = service.getValue<{
|
||||
foo: string;
|
||||
|
@ -78,7 +79,7 @@ suite('ConfigurationService - Node', () => {
|
|||
const newDir = path.join(parentDir, 'config', id);
|
||||
const testFile = path.join(newDir, 'config.json');
|
||||
|
||||
const service = new ConfigurationService(testFile);
|
||||
const service = new ConfigurationService(URI.file(testFile));
|
||||
await service.initialize();
|
||||
|
||||
const config = service.getValue<{ foo: string }>();
|
||||
|
@ -90,7 +91,7 @@ suite('ConfigurationService - Node', () => {
|
|||
test('trigger configuration change event', async () => {
|
||||
const res = await testFile('config', 'config.json');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
await service.initialize();
|
||||
return new Promise((c, e) => {
|
||||
service.onDidChangeConfiguration(() => {
|
||||
|
@ -108,7 +109,7 @@ suite('ConfigurationService - Node', () => {
|
|||
|
||||
fs.writeFileSync(res.testFile, '{ "foo": "bar" }');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
await service.initialize();
|
||||
let config = service.getValue<{
|
||||
foo: string;
|
||||
|
@ -157,7 +158,7 @@ suite('ConfigurationService - Node', () => {
|
|||
}
|
||||
});
|
||||
|
||||
let serviceWithoutFile = new ConfigurationService('__testFile');
|
||||
let serviceWithoutFile = new ConfigurationService(URI.file('__testFile'));
|
||||
await serviceWithoutFile.initialize();
|
||||
let setting = serviceWithoutFile.getValue<ITestSetting>();
|
||||
|
||||
|
@ -167,7 +168,7 @@ suite('ConfigurationService - Node', () => {
|
|||
return testFile('config', 'config.json').then(async res => {
|
||||
fs.writeFileSync(res.testFile, '{ "testworkbench.editor.tabs": true }');
|
||||
|
||||
const service = new ConfigurationService(res.testFile);
|
||||
const service = new ConfigurationService(URI.file(res.testFile));
|
||||
|
||||
let setting = service.getValue<ITestSetting>();
|
||||
|
||||
|
@ -200,7 +201,7 @@ suite('ConfigurationService - Node', () => {
|
|||
});
|
||||
|
||||
const r = await testFile('config', 'config.json');
|
||||
const service = new ConfigurationService(r.testFile);
|
||||
const service = new ConfigurationService(URI.file(r.testFile));
|
||||
service.initialize();
|
||||
|
||||
let res = service.inspect('something.missing');
|
||||
|
@ -238,7 +239,7 @@ suite('ConfigurationService - Node', () => {
|
|||
});
|
||||
|
||||
const r = await testFile('config', 'config.json');
|
||||
const service = new ConfigurationService(r.testFile);
|
||||
const service = new ConfigurationService(URI.file(r.testFile));
|
||||
service.initialize();
|
||||
|
||||
let res = service.inspect('lookup.service.testNullSetting');
|
||||
|
|
Loading…
Reference in a new issue