Skip to content

Commit 24ff688

Browse files
authored
Changed Editor.saveModule to only save if there are changes. (wpilibsuite#328)
1 parent a4db3ce commit 24ff688

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

src/editor/editor.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -301,19 +301,6 @@ export class Editor {
301301
}
302302
}
303303

304-
public isModified(): boolean {
305-
/*
306-
// This code is helpful for debugging issues where the editor says
307-
// 'Blocks have been modified!'.
308-
if (this.getModuleContentText() !== this.moduleContentText) {
309-
console.log('isModified will return true');
310-
console.log('this.getModuleContentText() is ' + this.getModuleContentText());
311-
console.log('this.moduleContentText is ' + this.moduleContentText);
312-
}
313-
*/
314-
return this.getModuleContentText() !== this.moduleContentText;
315-
}
316-
317304
public getBlocklyWorkspace(): Blockly.WorkspaceSvg {
318305
return this.blocklyWorkspace;
319306
}
@@ -470,12 +457,14 @@ export class Editor {
470457

471458
public async saveModule(): Promise<string> {
472459
const moduleContentText = this.getModuleContentText();
473-
try {
474-
await this.storage.saveFile(this.modulePath, moduleContentText);
475-
this.moduleContentText = moduleContentText;
476-
await storageProject.saveProjectInfo(this.storage, this.projectName);
477-
} catch (e) {
478-
throw e;
460+
if (moduleContentText !== this.moduleContentText) {
461+
try {
462+
await this.storage.saveFile(this.modulePath, moduleContentText);
463+
this.moduleContentText = moduleContentText;
464+
await storageProject.saveProjectInfo(this.storage, this.projectName);
465+
} catch (e) {
466+
throw e;
467+
}
479468
}
480469
return moduleContentText;
481470
}

0 commit comments

Comments
 (0)