Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support all arguments for monaco-vscode-api initialize #756

Merged
merged 8 commits into from
Oct 7, 2024
12 changes: 12 additions & 0 deletions packages/wrapper/test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* ------------------------------------------------------------------------------------------ */

import { WrapperConfig } from 'monaco-editor-wrapper';
import { useWorkerFactory } from 'monaco-editor-wrapper/workerFactory';

export const createMonacoEditorDiv = () => {
const div = document.createElement('div');
Expand Down Expand Up @@ -44,3 +45,14 @@ export const createWrapperConfigClassicApp = (): WrapperConfig => {
}
};
};

export const configureMonacoWorkers = () => {
useWorkerFactory({
workerOverrides: {
ignoreMapping: true,
workerLoaders: {
TextEditorWorker: () => new Worker(new URL('monaco-editor/esm/vs/editor/editor.worker.js', import.meta.url), { type: 'module' }),
}
}
});
};
17 changes: 12 additions & 5 deletions packages/wrapper/test/wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as vscode from 'vscode';
import { createModelReference } from 'vscode/monaco';
import { describe, expect, test } from 'vitest';
import { isReInitRequired, EditorAppClassic, EditorAppConfigExtended, MonacoEditorLanguageClientWrapper, EditorAppConfigClassic } from 'monaco-editor-wrapper';
import { createMonacoEditorDiv, createWrapperConfigClassicApp, createWrapperConfigExtendedApp } from './helper.js';
import { configureMonacoWorkers, createMonacoEditorDiv, createWrapperConfigClassicApp, createWrapperConfigExtendedApp } from './helper.js';
import { IConfigurationService, StandaloneServices } from 'vscode/services';

describe('Test MonacoEditorLanguageClientWrapper', () => {
Expand Down Expand Up @@ -230,17 +230,24 @@ describe('Test MonacoEditorLanguageClientWrapper', () => {
await wrapper.start();
});

test('config userConfiguration', async () => {
test('editorConfig semanticHighlighting.enabled workaround', async () => {
const wrapper = new MonacoEditorLanguageClientWrapper();
const wrapperConfig = createWrapperConfigClassicApp();
wrapperConfig.editorAppConfig.monacoWorkerFactory = configureMonacoWorkers;
(wrapperConfig.editorAppConfig as EditorAppConfigClassic).editorOptions = {
'semanticHighlighting.enabled': true,
};
const updatedWrapperConfig = await wrapper.init(wrapperConfig);
expect(updatedWrapperConfig.vscodeApiConfig?.workspaceConfig?.configurationDefaults?.['editor.semanticHighlighting.enabled']).toEqual(true);

// why is this configuredByTheme?
const semHigh = StandaloneServices.get(IConfigurationService).getValue('editor.semanticHighlighting.enabled');
expect(semHigh).toEqual('configuredByTheme');
// await wrapper.start();

const semHigh = await new Promise<unknown>(resolve => {
setTimeout(() => {
resolve(StandaloneServices.get(IConfigurationService).getValue('editor.semanticHighlighting.enabled'));
}, 1000);
kaisalmen marked this conversation as resolved.
Show resolved Hide resolved
});
// const semHigh = StandaloneServices.get(IConfigurationService).getValue('editor.semanticHighlighting.enabled');
expect(semHigh).toEqual(true);
});
});