Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Implemented review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisalmen committed Sep 18, 2023
1 parent 54311d4 commit 52e9cdf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const setupLangiumClientClassic = async (): Promise<UserConfig> => {
languageId: 'langium',
code: code,
useDiffEditor: false,
// configure it like this or in the userConfiguration
editorOptions: {
'semanticHighlighting.enabled': true
},
Expand All @@ -38,8 +39,9 @@ export const setupLangiumClientClassic = async (): Promise<UserConfig> => {
themeData: LangiumTheme,
theme: 'langium-theme',
userConfiguration: {
json: '{}'
// or configure the semantic highlighting like this:
// `{ json: "editor.semanticHighlighting.enabled": true }`
json: '{}'
}
}
},
Expand Down
15 changes: 8 additions & 7 deletions packages/monaco-editor-react/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EditorAppConfigClassic, MonacoEditorLanguageClientWrapper, UserConfig, WorkerConfigDirect, WorkerConfigOptions } from 'monaco-editor-wrapper';
import { EditorAppClassic, EditorAppConfigClassic, MonacoEditorLanguageClientWrapper, UserConfig, WorkerConfigDirect, WorkerConfigOptions } from 'monaco-editor-wrapper';
import { IDisposable } from 'monaco-editor';
import * as vscode from 'vscode';
import React, { CSSProperties } from 'react';
Expand Down Expand Up @@ -73,17 +73,18 @@ export class MonacoEditorReactComp extends React.Component<MonacoEditorProps> {
}

if (!restarted) {
if (userConfig.wrapperConfig.editorAppConfig.$type === 'classic') {
const options = (userConfig.wrapperConfig.editorAppConfig as EditorAppConfigClassic).editorOptions;
const appConfig = userConfig.wrapperConfig.editorAppConfig;
if (appConfig.$type === 'classic') {
const options = (appConfig as EditorAppConfigClassic).editorOptions;
const prevOptions = (prevProps.userConfig.wrapperConfig.editorAppConfig as EditorAppConfigClassic).editorOptions;
if (options !== prevOptions) {
wrapper.updateEditorOptions((userConfig.wrapperConfig.editorAppConfig as EditorAppConfigClassic).editorOptions ?? {});
if (options !== prevOptions && options !== undefined) {
(wrapper.getMonacoEditorApp() as EditorAppClassic).updateMonacoEditorOptions(options);
}
}

const languageId = userConfig.wrapperConfig.editorAppConfig.languageId;
const languageId = appConfig.languageId;
const code = appConfig.code;
const prevLanguageId = prevProps.userConfig.wrapperConfig.editorAppConfig.languageId;
const code = userConfig.wrapperConfig.editorAppConfig.code;
const prevCode = prevProps.userConfig.wrapperConfig.editorAppConfig.code;
if (languageId !== prevLanguageId && code !== prevCode) {
this.wrapper.updateModel({
Expand Down
7 changes: 3 additions & 4 deletions packages/monaco-editor-wrapper/src/editorAppBase.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { editor, Uri } from 'monaco-editor';
import { createConfiguredEditor, createConfiguredDiffEditor, createModelReference, ITextFileEditorModel } from 'vscode/monaco';
import { IReference } from 'vscode/service-override/editor';
import { updateUserConfiguration } from 'vscode/service-override/configuration';
import { updateUserConfiguration as vscodeUpdateUserConfiguratio } from 'vscode/service-override/configuration';
import { ModelUpdate, UserConfig, WrapperConfig } from './wrapper.js';
import { EditorAppConfigClassic } from './editorAppClassic.js';
import { EditorAppConfigVscodeApi } from './editorAppVscodeApi.js';
Expand Down Expand Up @@ -47,7 +47,7 @@ export abstract class EditorAppBase {

protected buildConfig(userConfig: UserConfig): EditorAppBaseConfig {
const userAppConfig = userConfig.wrapperConfig.editorAppConfig;
const config = {
return {
languageId: userAppConfig.languageId,
code: userAppConfig.code ?? '',
codeOriginal: userAppConfig.codeOriginal ?? '',
Expand All @@ -60,7 +60,6 @@ export abstract class EditorAppBase {
json: '{}'
}
};
return config;
}

haveEditor() {
Expand Down Expand Up @@ -209,7 +208,7 @@ export abstract class EditorAppBase {

async updateUserConfiguration(config: UserConfiguration) {
if (config.json) {
return updateUserConfiguration(config.json);
return vscodeUpdateUserConfiguratio(config.json);
}
return Promise.reject(new Error('Supplied config is undefined'));
}
Expand Down
8 changes: 0 additions & 8 deletions packages/monaco-editor-wrapper/src/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,6 @@ export class MonacoEditorLanguageClientWrapper {
return this.editorApp?.updateUserConfiguration(config);
}

async updateEditorOptions(options: editor.IEditorOptions & editor.IGlobalEditorOptions): Promise<void> {
if (this.editorApp && this.editorApp.getAppType() === 'classic') {
await (this.editorApp as EditorAppClassic).updateMonacoEditorOptions(options);
} else {
await Promise.reject('updateEditorOptions was called where editorApp is not of appType classic.');
}
}

public reportStatus() {
const status: string[] = [];
status.push('Wrapper status:');
Expand Down

0 comments on commit 52e9cdf

Please sign in to comment.