diff --git a/apps/remix-ide/src/app/editor/editor.js b/apps/remix-ide/src/app/editor/editor.js index 9fe194eeab..9bf7e3fec6 100644 --- a/apps/remix-ide/src/app/editor/editor.js +++ b/apps/remix-ide/src/app/editor/editor.js @@ -143,6 +143,7 @@ class Editor extends Plugin { this.on('fileManager', 'fileClosed', (name) => { if (name === this.currentFile) { this.currentFile = null + this.renderComponent() } }) this.on('theme', 'themeLoaded', (theme) => { diff --git a/apps/remix-ide/src/app/panels/tab-proxy.js b/apps/remix-ide/src/app/panels/tab-proxy.js index f9a11c2b93..ec8026c517 100644 --- a/apps/remix-ide/src/app/panels/tab-proxy.js +++ b/apps/remix-ide/src/app/panels/tab-proxy.js @@ -153,6 +153,10 @@ export class TabProxy extends Plugin { displayName, () => this.emit('switchApp', name), () => { + if (name === 'home' && this.loadedTabs.length === 1 && this.loadedTabs[0].id === "home") { + const files = Object.keys(this.editor.sessions) + files.forEach(filepath => this.editor.discard(filepath)) + } this.emit('closeApp', name) this.call('manager', 'deactivatePlugin', name) }, 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 7bc0efe7b0..0c718a8865 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -228,7 +228,7 @@ export const EditorUI = (props: EditorUIProps) => { useEffect(() => { - if (!editorRef.current) return + if (!editorRef.current || !props.currentFile) return currentFileRef.current = props.currentFile const file = editorModelsState[props.currentFile] editorRef.current.setModel(file.model)