Skip to content

Commit 4596e62

Browse files
committed
Fix saving dependency to pkg.json
1 parent bbd8d5f commit 4596e62

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

packages/app/src/app/overmind/effects/vscode/ModelsHandler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ export class ModelsHandler {
153153
);
154154
}
155155

156+
public isModuleOpened(module: Module) {
157+
const moduleModel = this.getModuleModelByPath(module.path);
158+
return Boolean(moduleModel?.model);
159+
}
160+
156161
public changeModule = async (module: Module) => {
157162
const moduleModel = this.getOrCreateModuleModelByPath(module.path);
158163

packages/app/src/app/overmind/effects/vscode/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ export class VSCodeEffect {
220220
return this.initialized;
221221
}
222222

223+
public isModuleOpened(module: Module) {
224+
return this.modelsHandler.isModuleOpened(module);
225+
}
226+
223227
public async getCodeReferenceBoundary(
224228
commentId: string,
225229
reference: Reference

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ export const saveCode: AsyncAction<{
141141
updatedModule.code === module.code ? null : updatedModule.code;
142142

143143
module.savedCode = savedCode;
144+
if (!effects.vscode.isModuleOpened(module)) {
145+
module.code = savedCode;
146+
}
144147

145148
effects.vscode.sandboxFsSync.writeFile(state.editor.modulesByPath, module);
146149
if (savedCode === null) {

packages/app/src/app/overmind/namespaces/live/liveMessageOperators.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ export const onModuleSaved: Operator<LiveMessage<{
178178

179179
effects.vscode.sandboxFsSync.writeFile(state.editor.modulesByPath, module);
180180
const savedCode = getSavedCode(module.code, module.savedCode);
181+
if (!effects.vscode.isModuleOpened(module)) {
182+
module.code = savedCode;
183+
}
181184
if (module.code === savedCode) {
182185
// We revert the module so that VSCode will flag saved indication correctly
183186
effects.vscode.syncModule(module);

0 commit comments

Comments
 (0)