Skip to content

Commit 32ae893

Browse files
fix issue, also in production, deleting directories with files
1 parent 20e16c8 commit 32ae893

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/app/src/app/overmind/namespaces/editor/actions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,10 @@ export const likeSandboxToggled: AsyncAction<{
300300
state.editor.sandboxes[id].userLiked = !state.editor.sandboxes[id].userLiked;
301301
};
302302

303-
// This might be called from explorer or vscode
304303
export const moduleSelected: Action<{
304+
// Path means it is coming from VSCode
305305
path?: string;
306+
// Id means it is coming from Explorer
306307
id?: string;
307308
}> = ({ state, effects, actions }, { path, id }) => {
308309
effects.analytics.track('Open File');
@@ -358,7 +359,8 @@ export const moduleSelected: Action<{
358359
effects.live.sendUserCurrentModule(module.shortid);
359360
}
360361
} catch (error) {
361-
state.editor.currentModuleShortid = null;
362+
// Do nothing, it is most likely VSCode selecting a file
363+
// that is deleted... yeah... it does that
362364
}
363365
};
364366

packages/app/src/app/overmind/namespaces/files/actions.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,12 @@ export const directoryDeleted: AsyncAction<{
214214
)[0];
215215

216216
state.editor.currentModuleShortid = state.editor.mainModule.shortid;
217-
effects.vscode.fs.rmdir(state.editor.modulesByPath, removedDirectory);
217+
218+
// we need to recreate everything, as you might have deleted any number
219+
// of nested directories or files
220+
state.editor.modulesByPath = effects.vscode.fs.create(sandbox);
221+
effects.vscode.openModule(state.editor.currentModule);
222+
218223
try {
219224
await effects.api.deleteDirectory(state.editor.currentId, directoryShortid);
220225
effects.live.sendDirectoryDeleted(directoryShortid);

0 commit comments

Comments
 (0)