Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* fix microsoft#209311

* fix test
  • Loading branch information
sandy081 authored Apr 9, 2024
1 parent 800d68a commit e2f29f7
Show file tree
Hide file tree
Showing 18 changed files with 395 additions and 270 deletions.
24 changes: 19 additions & 5 deletions src/vs/editor/standalone/browser/standaloneServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import { getEditorFeatures } from 'vs/editor/common/editorFeatures';
import { onUnexpectedError } from 'vs/base/common/errors';
import { ExtensionKind, IEnvironmentService, IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
import { mainWindow } from 'vs/base/browser/window';
import { ResourceMap } from 'vs/base/common/map';

class SimpleModel implements IResolvedTextEditorModel {

Expand Down Expand Up @@ -629,9 +630,22 @@ export class StandaloneConfigurationService implements IConfigurationService {

private readonly _configuration: Configuration;

constructor() {
const defaultConfiguration = new DefaultConfiguration();
this._configuration = new Configuration(defaultConfiguration.reload(), new ConfigurationModel(), new ConfigurationModel(), new ConfigurationModel());
constructor(
@ILogService private readonly logService: ILogService,
) {
const defaultConfiguration = new DefaultConfiguration(logService);
this._configuration = new Configuration(
defaultConfiguration.reload(),
ConfigurationModel.createEmptyModel(logService),
ConfigurationModel.createEmptyModel(logService),
ConfigurationModel.createEmptyModel(logService),
ConfigurationModel.createEmptyModel(logService),
ConfigurationModel.createEmptyModel(logService),
new ResourceMap<ConfigurationModel>(),
ConfigurationModel.createEmptyModel(logService),
new ResourceMap<ConfigurationModel>(),
logService
);
defaultConfiguration.dispose();
}

Expand Down Expand Up @@ -660,7 +674,7 @@ export class StandaloneConfigurationService implements IConfigurationService {
}

if (changedKeys.length > 0) {
const configurationChangeEvent = new ConfigurationChangeEvent({ keys: changedKeys, overrides: [] }, previous, this._configuration);
const configurationChangeEvent = new ConfigurationChangeEvent({ keys: changedKeys, overrides: [] }, previous, this._configuration, undefined, this.logService);
configurationChangeEvent.source = ConfigurationTarget.MEMORY;
this._onDidChangeConfiguration.fire(configurationChangeEvent);
}
Expand Down Expand Up @@ -1092,6 +1106,7 @@ export interface IEditorOverrideServices {
[index: string]: any;
}

registerSingleton(ILogService, StandaloneLogService, InstantiationType.Eager);
registerSingleton(IConfigurationService, StandaloneConfigurationService, InstantiationType.Eager);
registerSingleton(ITextResourceConfigurationService, StandaloneResourceConfigurationService, InstantiationType.Eager);
registerSingleton(ITextResourcePropertiesService, StandaloneResourcePropertiesService, InstantiationType.Eager);
Expand All @@ -1104,7 +1119,6 @@ registerSingleton(INotificationService, StandaloneNotificationService, Instantia
registerSingleton(IMarkerService, MarkerService, InstantiationType.Eager);
registerSingleton(ILanguageService, StandaloneLanguageService, InstantiationType.Eager);
registerSingleton(IStandaloneThemeService, StandaloneThemeService, InstantiationType.Eager);
registerSingleton(ILogService, StandaloneLogService, InstantiationType.Eager);
registerSingleton(IModelService, ModelService, InstantiationType.Eager);
registerSingleton(IMarkerDecorationsService, MarkerDecorationsService, InstantiationType.Eager);
registerSingleton(IContextKeyService, ContextKeyService, InstantiationType.Eager);
Expand Down
15 changes: 8 additions & 7 deletions src/vs/editor/standalone/test/browser/monarch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { compile } from 'vs/editor/standalone/common/monarch/monarchCompile';
import { MonarchTokenizer } from 'vs/editor/standalone/common/monarch/monarchLexer';
import { IMonarchLanguage } from 'vs/editor/standalone/common/monarch/monarchTypes';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { NullLogService } from 'vs/platform/log/common/log';

suite('Monarch', () => {

Expand All @@ -37,7 +38,7 @@ suite('Monarch', () => {
test('Ensure @rematch and nextEmbedded can be used together in Monarch grammar', () => {
const disposables = new DisposableStore();
const languageService = disposables.add(new LanguageService());
const configurationService = new StandaloneConfigurationService();
const configurationService = new StandaloneConfigurationService(new NullLogService());
disposables.add(languageService.registerLanguage({ id: 'sql' }));
disposables.add(TokenizationRegistry.register('sql', disposables.add(createMonarchTokenizer(languageService, 'sql', {
tokenizer: {
Expand Down Expand Up @@ -113,7 +114,7 @@ suite('Monarch', () => {

test('microsoft/monaco-editor#1235: Empty Line Handling', () => {
const disposables = new DisposableStore();
const configurationService = new StandaloneConfigurationService();
const configurationService = new StandaloneConfigurationService(new NullLogService());
const languageService = disposables.add(new LanguageService());
const tokenizer = disposables.add(createMonarchTokenizer(languageService, 'test', {
tokenizer: {
Expand Down Expand Up @@ -172,7 +173,7 @@ suite('Monarch', () => {

test('microsoft/monaco-editor#2265: Exit a state at end of line', () => {
const disposables = new DisposableStore();
const configurationService = new StandaloneConfigurationService();
const configurationService = new StandaloneConfigurationService(new NullLogService());
const languageService = disposables.add(new LanguageService());
const tokenizer = disposables.add(createMonarchTokenizer(languageService, 'test', {
includeLF: true,
Expand Down Expand Up @@ -223,7 +224,7 @@ suite('Monarch', () => {

test('issue #115662: monarchCompile function need an extra option which can control replacement', () => {
const disposables = new DisposableStore();
const configurationService = new StandaloneConfigurationService();
const configurationService = new StandaloneConfigurationService(new NullLogService());
const languageService = disposables.add(new LanguageService());

const tokenizer1 = disposables.add(createMonarchTokenizer(languageService, 'test', {
Expand Down Expand Up @@ -280,7 +281,7 @@ suite('Monarch', () => {

test('microsoft/monaco-editor#2424: Allow to target @@', () => {
const disposables = new DisposableStore();
const configurationService = new StandaloneConfigurationService();
const configurationService = new StandaloneConfigurationService(new NullLogService());
const languageService = disposables.add(new LanguageService());

const tokenizer = disposables.add(createMonarchTokenizer(languageService, 'test', {
Expand Down Expand Up @@ -312,7 +313,7 @@ suite('Monarch', () => {
test('microsoft/monaco-editor#3025: Check maxTokenizationLineLength before tokenizing', async () => {
const disposables = new DisposableStore();

const configurationService = new StandaloneConfigurationService();
const configurationService = new StandaloneConfigurationService(new NullLogService());
const languageService = disposables.add(new LanguageService());

// Set maxTokenizationLineLength to 4 so that "ham" works but "hamham" would fail
Expand Down Expand Up @@ -348,7 +349,7 @@ suite('Monarch', () => {

test('microsoft/monaco-editor#3128: allow state access within rules', () => {
const disposables = new DisposableStore();
const configurationService = new StandaloneConfigurationService();
const configurationService = new StandaloneConfigurationService(new NullLogService());
const languageService = disposables.add(new LanguageService());

const tokenizer = disposables.add(createMonarchTokenizer(languageService, 'test', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ suite('StandaloneKeybindingService', () => {
const disposables = new DisposableStore();
const serviceCollection = new ServiceCollection();
const instantiationService = new InstantiationService(serviceCollection, true);
const configurationService = new StandaloneConfigurationService();
const configurationService = new StandaloneConfigurationService(new NullLogService());
const contextKeyService = disposables.add(new ContextKeyService(configurationService));
const commandService = new StandaloneCommandService(instantiationService);
const notificationService = new StandaloneNotificationService();
Expand Down
4 changes: 4 additions & 0 deletions src/vs/platform/configuration/common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ export function addToValueTree(settingsTreeRoot: any, key: string, value: any, c
obj = curr[s] = Object.create(null);
break;
case 'object':
if (obj === null) {
conflictReporter(`Ignoring ${key} as ${segments.slice(0, i + 1).join('.')} is null`);
return;
}
break;
default:
conflictReporter(`Ignoring ${key} as ${segments.slice(0, i + 1).join('.')} is ${JSON.stringify(obj)}`);
Expand Down
Loading

0 comments on commit e2f29f7

Please sign in to comment.