diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 90b54a103..db6ed2383 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -602,32 +602,37 @@ public class Base { } + /** + * The call has already checked to make sure this sketch is not modified, + * now change the mode. + */ protected void changeMode(Mode mode) { if (activeEditor.getMode() != mode) { Sketch sketch = activeEditor.getSketch(); nextMode = mode; - - // If the current editor contains file extensions that the new mode can handle, then - // write a sketch.properties file with the new mode specified, and reopen. - boolean newModeCanHandleCurrentSource = true; - for (final SketchCode code: sketch.getCode()) { - if (!mode.validExtension(code.getExtension())) { - newModeCanHandleCurrentSource = false; - break; - } - } - if (newModeCanHandleCurrentSource) { - final File props = new File(sketch.getCodeFolder(), "sketch.properties"); - saveModeSettings(props, nextMode); + + if (sketch.isUntitled()) { + // If no changes have been made, just close and start fresh. + // (Otherwise the editor would lose its 'untitled' status.) handleClose(activeEditor, true); - handleOpen(sketch.getMainFilePath()); - } else { - // If you're changing modes, and there's nothing in the current sketch, you probably - // don't intend to keep the old, wrong-mode editor around. - if (sketch.isUntitled()) { - handleClose(activeEditor, true); - } handleNew(); + + } else { + // If the current editor contains file extensions that the new mode can handle, then + // write a sketch.properties file with the new mode specified, and reopen. + boolean newModeCanHandleCurrentSource = true; + for (final SketchCode code: sketch.getCode()) { + if (!mode.validExtension(code.getExtension())) { + newModeCanHandleCurrentSource = false; + break; + } + } + if (newModeCanHandleCurrentSource) { + final File props = new File(sketch.getCodeFolder(), "sketch.properties"); + saveModeSettings(props, nextMode); + handleClose(activeEditor, true); + handleOpen(sketch.getMainFilePath()); + } } } } diff --git a/todo.txt b/todo.txt index dd90e7178..929f36f12 100644 --- a/todo.txt +++ b/todo.txt @@ -42,7 +42,7 @@ X https://github.com/processing/processing/issues/2194 X remove default menu bar hack when 7u60 arrives X http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8022667 X when renaming a tab, include the previous name to be edited -_ changing the mode on an untitled, unmodified sketch removes untitled status +X changing the mode on an untitled, unmodified sketch removes untitled status gsoc X clear status messages in the Contribution Manager