Skip to content

Commit 1f1d022

Browse files
committed
More debug
1 parent af01897 commit 1f1d022

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jderobot-ide-interface",
3-
"version": "0.2.58",
3+
"version": "0.2.59",
44
"main": "dist/main.js",
55
"typings": "dist/index.d.ts",
66
"files": [

src/components/FileEditor/TextEditor.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useReducer } from "react";
1+
import React from "react";
22
import { useEffect, useRef, useState } from "react";
33
import Editor, { Monaco } from "@monaco-editor/react";
44
import type { editor } from "monaco-editor";
@@ -52,8 +52,6 @@ const FileEditor = ({
5252
extraSnippets?: ExtraSnippets;
5353
}) => {
5454
const theme = useTheme();
55-
const [, forceUpdate] = useReducer(x => x + 1, 0);
56-
const [lang, setLang] = useState(language);
5755

5856
const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);
5957
const monacoRef = useRef<Monaco | null>(null);
@@ -167,6 +165,9 @@ const FileEditor = ({
167165
"editor.background": theme.palette.background,
168166
},
169167
});
168+
console.log(
169+
monaco.editor.getEditors()[0].getModel()?.getLanguageId()
170+
)
170171
};
171172

172173
const handleEditorMount = async (
@@ -272,10 +273,6 @@ const FileEditor = ({
272273
setFontSize(Math.max(10, 14 + zoomLevel * 2));
273274
}, [zoomLevel]);
274275

275-
useEffect(() => {
276-
setLang(language)
277-
}, [language]);
278-
279276
// Code Analysis (with pylint)
280277
useEffect(() => {
281278
if (
@@ -322,22 +319,27 @@ const FileEditor = ({
322319
);
323320
}, [fileContent]);
324321

322+
console.log(language)
323+
325324
return (
326-
<Editor
327-
width="100%"
328-
height="100%"
329-
defaultLanguage={"python"}
330-
defaultValue=""
331-
language={lang}
332-
value={fileContent}
333-
theme={`${theme.monacoTheme}-theme`}
334-
onChange={(newContent: any) => {
335-
setFileContent(newContent);
336-
}}
337-
options={editorOptions}
338-
beforeMount={handleEditorDidMount}
339-
onMount={handleEditorMount}
340-
/>
325+
<>
326+
{language && (
327+
<Editor
328+
width="100%"
329+
height="100%"
330+
defaultValue=""
331+
language={language}
332+
value={fileContent}
333+
theme={`${theme.monacoTheme}-theme`}
334+
onChange={(newContent: any) => {
335+
setFileContent(newContent);
336+
}}
337+
options={editorOptions}
338+
beforeMount={handleEditorDidMount}
339+
onMount={handleEditorMount}
340+
/>
341+
)}
342+
</>
341343
);
342344
};
343345

0 commit comments

Comments
 (0)