From c790b92a0c5f5afd73f7b4e4f342e0c4baaaa261 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Tue, 4 Jun 2024 11:33:39 +0200 Subject: [PATCH] fix bugs --- libs/remix-ui/editor/src/lib/actions/editor.ts | 5 +++-- libs/remix-ui/editor/src/lib/remix-ui-editor.tsx | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libs/remix-ui/editor/src/lib/actions/editor.ts b/libs/remix-ui/editor/src/lib/actions/editor.ts index d94e9b8e39..b367b79a2b 100644 --- a/libs/remix-ui/editor/src/lib/actions/editor.ts +++ b/libs/remix-ui/editor/src/lib/actions/editor.ts @@ -5,14 +5,14 @@ export interface Action { type: string; payload: Record monaco: any, - editor: any + editors: any[] } export const initialState = {} export const reducerActions = (models = initialState, action: Action) => { const monaco = action.monaco - const editors = action.editor as any[] + const editors = action.editors as any[] switch (action.type) { case 'ADD_MODEL': { if (!editors) return models @@ -23,6 +23,7 @@ export const reducerActions = (models = initialState, action: Action) => { if (models[uri]) return models // already existing models[uri] = { language, uri, readOnly } let model + try { model = monaco.editor.createModel(value, language, monaco.Uri.parse(uri)) } catch (e) { diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index 81d31dd4bb..32a2fcb3db 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -631,6 +631,12 @@ export const EditorUI = (props: EditorUIProps) => { } function setReducerListener() { + if(!diffEditorRef.current && editorRef.current){ + reducerListener(props.plugin, dispatch, monacoRef.current, [editorRef.current], props.events) + } + if(diffEditorRef.current && diffEditorRef.current.getModifiedEditor() && !editorRef.current){ + reducerListener(props.plugin, dispatch, monacoRef.current, [diffEditorRef.current.getModifiedEditor()], props.events) + } if(diffEditorRef.current && diffEditorRef.current.getModifiedEditor() && editorRef.current){ reducerListener(props.plugin, dispatch, monacoRef.current, [diffEditorRef.current.getModifiedEditor(), editorRef.current], props.events) }