Skip to content

Commit 13caca5

Browse files
committed
In project.ts renameOrCopyModule function to change the ids in the copy.
1 parent 9b4478e commit 13caca5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/storage/project.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,13 @@ async function renameOrCopyModule(
287287
storage: commonStorage.Storage, project: Project, newClassName: string,
288288
oldModule: storageModule.Module, rename: boolean): Promise<string> {
289289
const newModulePath = storageNames.makeModulePath(project.projectName, newClassName);
290-
const moduleContentText = await storage.fetchModuleContentText(oldModule.modulePath);
290+
let moduleContentText = await storage.fetchModuleContentText(oldModule.modulePath);
291+
if (!rename) {
292+
// Change the ids in the module.
293+
const moduleContent = storageModuleContent.parseModuleContentText(moduleContentText);
294+
moduleContent.changeIds();
295+
moduleContentText = moduleContent.getModuleContentText();
296+
}
291297
await storage.saveModule(newModulePath, moduleContentText);
292298
if (rename) {
293299
// For rename, delete the old module.
@@ -462,7 +468,7 @@ async function processUploadedBlob(blobUrl: string): Promise<{ [className: strin
462468
});
463469

464470
// Wait for all promises to resolve.
465-
const files: { [key: string]: string } = {}; // key is file name, value is content
471+
const files: { [fileName: string]: string } = {}; // value is file content
466472
await Promise.all(
467473
Object.entries(promises).map(async ([filename, promise]) => {
468474
files[filename] = await promise;

0 commit comments

Comments
 (0)