Skip to content

Commit ccec28e

Browse files
matthijskooijmanfacchinm
authored andcommitted
Move sketch deletion from SketchController into Sketch
This isn't much code, but it makes deletion more consistent with renaming and saving with the SketchController handling the UI part and Sketch actually doing the delete.
1 parent 85d4839 commit ccec28e

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

app/src/processing/app/SketchController.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,20 +249,8 @@ public void handleDeleteCode() throws IOException {
249249
options[0]);
250250
if (result == JOptionPane.YES_OPTION) {
251251
if (current.isPrimary()) {
252-
// need to unset all the modified flags, otherwise tries
253-
// to do a save on the handleNew()
254-
255-
// delete the entire sketch
256-
FileUtils.recursiveDelete(sketch.getFolder());
257-
258-
// get the changes into the sketchbook menu
259-
//sketchbook.rebuildMenus();
260-
261-
// make a new sketch, and i think this will rebuild the sketch menu
262-
//editor.handleNewUnchecked();
263-
//editor.handleClose2();
252+
sketch.delete();
264253
editor.base.handleClose(editor);
265-
266254
} else {
267255
// delete the file
268256
if (!current.deleteFile(BaseNoGui.getBuildFolder(sketch).toPath())) {

arduino-core/src/processing/app/Sketch.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,11 @@ public void saveAs(File newFolder) throws IOException {
332332
FileUtils.copy(getDataFolder(), newDataFolder);
333333
}
334334
}
335+
336+
/**
337+
* Deletes this entire sketch from disk.
338+
*/
339+
void delete() {
340+
FileUtils.recursiveDelete(folder);
341+
}
335342
}

0 commit comments

Comments
 (0)