Skip to content

Commit 039528a

Browse files
committed
Fix weird behavior when content has empty string
1 parent 505cd60 commit 039528a

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/components/Editor/Editor.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const Editor:React.FC<EditorTypes> = ({ content, setContent }) => {
1616
const [ lintErrors, setLintErrors ] = useState<any[]>([]);
1717

1818
useEffect(() => {
19-
content && lintScan(content).then((res:any) => {
19+
content != null && lintScan(content).then((res:any) => {
2020
setLintErrors(res);
2121
applyErrorMarkers(res, editorRef.current, monacoRef.current)
2222
});
@@ -29,7 +29,7 @@ const Editor:React.FC<EditorTypes> = ({ content, setContent }) => {
2929
size={'80%'}
3030
>
3131
<div className="monaco-editor-wrapper">
32-
<MonacoEditor editorRef={editorRef} monacoRef={monacoRef} content={content} setContent={setContent} />
32+
{content != null && <MonacoEditor editorRef={editorRef} monacoRef={monacoRef} content={content} setContent={setContent} />}
3333
</div>
3434
<EditorTerminal editorRef={editorRef} lintErrors={lintErrors} />
3535
</ReactSplitPane>

src/components/Editor/components/MonacoEditor.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ const MonacoEditor:React.FC<MonacoEditorTypes> = ({ editorRef, monacoRef, conten
2525
}
2626
return(<>
2727
{
28-
content
29-
? <Editor
28+
<Editor
3029
onMount={handleEditorDidMount}
3130
height="100%"
3231
defaultLanguage="json"
@@ -38,9 +37,6 @@ const MonacoEditor:React.FC<MonacoEditorTypes> = ({ editorRef, monacoRef, conten
3837
foldingStrategy: "indentation"
3938
}}
4039
/>
41-
: <div className="d-flex align-items-center justify-content-center h-100">
42-
<Spinner />
43-
</div>
4440
}
4541
</>)
4642
}

0 commit comments

Comments
 (0)