Optimize CodeEditor

This commit is contained in:
2024-01-22 16:06:09 +08:00
parent 3a973a3c93
commit 8a954abedf
3 changed files with 6 additions and 4 deletions

View File

@@ -48,7 +48,8 @@ const Editor = ({
tsconfig.compilerOptions
)
files &&
if (files) {
monaco.editor.getModels().forEach((model) => model.dispose())
Object.entries(files).forEach(([key]) => {
if (!monaco.editor.getModel(monaco.Uri.parse(`file:///${key}`))) {
monaco.editor.createModel(
@@ -58,6 +59,7 @@ const Editor = ({
)
}
})
}
}
const handleOnEditorDidMount = (editor: editor.IStandaloneCodeEditor, monaco: Monaco) => {