Skip to content

Commit 44b3495

Browse files
committed
fix: Ensure initial code is correctly loaded when switching languages in the IDE panel.
1 parent 86f8257 commit 44b3495

File tree

7 files changed

+591
-440
lines changed

7 files changed

+591
-440
lines changed

Context/SELF_ASSESSMENT_REPORT_LEARNIX.md

Lines changed: 127 additions & 121 deletions
Large diffs are not rendered by default.

apps/web/src/components/ide/code-editor.tsx

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,45 @@ import { useRef } from 'react';
33
import MonacoEditor, { type OnMount } from '@monaco-editor/react';
44

55
interface CodeEditorProps {
6-
initialValue: string;
7-
language: string;
8-
onChange?: (value: string | undefined) => void;
9-
theme?: 'vs-dark' | 'light';
10-
readOnly?: boolean;
6+
initialValue: string;
7+
language: string;
8+
onChange?: (value: string | undefined) => void;
9+
theme?: 'vs-dark' | 'light';
10+
readOnly?: boolean;
1111
}
1212

1313
export function CodeEditor({
14-
initialValue,
15-
language,
16-
onChange,
17-
theme = 'vs-dark',
18-
readOnly = false,
14+
initialValue,
15+
language,
16+
onChange,
17+
theme = 'vs-dark',
18+
readOnly = false,
1919
}: CodeEditorProps) {
20-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
21-
const editorRef = useRef<any>(null);
20+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
21+
const editorRef = useRef<any>(null);
2222

23-
const handleEditorDidMount: OnMount = (editor, _monaco) => {
24-
editorRef.current = editor;
25-
};
23+
const handleEditorDidMount: OnMount = (editor, _monaco) => {
24+
editorRef.current = editor;
25+
};
2626

27-
return (
28-
<div className="h-full w-full rounded-md overflow-hidden border border-border">
29-
<MonacoEditor
30-
height="100%"
31-
width="100%"
32-
language={language}
33-
value={initialValue}
34-
theme={theme}
35-
onChange={onChange}
36-
onMount={handleEditorDidMount}
37-
options={{
38-
readOnly,
39-
minimap: { enabled: false },
40-
scrollBeyondLastLine: false,
41-
fontSize: 14,
42-
padding: { top: 16, bottom: 16 },
43-
}}
44-
/>
45-
</div>
46-
);
27+
return (
28+
<div className="h-full w-full rounded-md overflow-hidden border border-border">
29+
<MonacoEditor
30+
height="100%"
31+
width="100%"
32+
language={language}
33+
value={initialValue}
34+
theme={theme}
35+
onChange={onChange}
36+
onMount={handleEditorDidMount}
37+
options={{
38+
readOnly,
39+
minimap: { enabled: false },
40+
scrollBeyondLastLine: false,
41+
fontSize: 14,
42+
padding: { top: 16, bottom: 16 },
43+
}}
44+
/>
45+
</div>
46+
);
4747
}

0 commit comments

Comments
 (0)