Skip to content

Commit 8b5a7ca

Browse files
fix closing and opening file
1 parent ec53673 commit 8b5a7ca

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,26 +205,22 @@ export class ModelsHandler {
205205

206206
// Ensure we have the moduleModels
207207
Object.keys(commentThreadsByPath).forEach(path => {
208-
// TODO(@christianalfoni): We should probably make this dynamic on model load instead of
209-
// on editor load? Preferably we don't keep all moduleModels for files that are not opened.
210208
this.getOrCreateModuleModelByPath(path).comments =
211209
commentThreadsByPath[path];
212210
});
213211

214212
// Apply the decorations
215213
Object.keys(this.moduleModels).forEach(path => {
216214
const moduleModel = this.moduleModels[path];
217-
const relativePath = path.replace('/sandbox', '');
218215
const model = moduleModel.model;
219216

220217
if (!model) {
221218
return;
222219
}
223220

224-
const commentThreads = commentThreadsByPath[relativePath] || [];
225221
const existingDecorationComments = moduleModel.currentCommentDecorations;
226222
const newDecorationComments = this.createCommentDecorations(
227-
commentThreads,
223+
moduleModel.comments,
228224
model,
229225
currentCommentThreadId,
230226
moduleModel.currentLine
@@ -234,8 +230,6 @@ export class ModelsHandler {
234230
existingDecorationComments,
235231
newDecorationComments
236232
);
237-
238-
moduleModel.comments = commentThreads;
239233
});
240234
}
241235

@@ -736,7 +730,9 @@ export class ModelsHandler {
736730
const csbPath = model.uri.path.replace('/sandbox', '');
737731
dispatch(actions.correction.clear(csbPath, 'eslint'));
738732

739-
delete this.moduleModels[model.uri.path];
733+
// We only delete the model, because the state contains things
734+
// like comments, which we want to keep
735+
delete this.moduleModels[model.uri.path].model;
740736
}
741737
}
742738
);

0 commit comments

Comments
 (0)