@@ -181,7 +181,7 @@ protected void nameCode(String newName) {
181
181
// Don't let the user create the main tab as a .java file instead of .pde
182
182
if (!isDefaultExtension (newExtension )) {
183
183
if (renamingCode ) { // If creating a new tab, don't show this error
184
- if (current == sketch . getCode ( 0 )) { // If this is the main tab, disallow
184
+ if (current . isPrimary ( )) { // If this is the main tab, disallow
185
185
Base .showWarning (tr ("Problem with rename" ),
186
186
tr ("The main file can't use an extension.\n " +
187
187
"(It may be time for your to graduate to a\n " +
@@ -572,9 +572,8 @@ protected boolean saveAs() throws IOException {
572
572
// make sure there doesn't exist a .cpp file with that name already
573
573
// but ignore this situation for the first tab, since it's probably being
574
574
// resaved (with the same name) to another location/folder.
575
- for (int i = 1 ; i < sketch .getCodeCount (); i ++) {
576
- SketchCode code = sketch .getCode (i );
577
- if (newName .equalsIgnoreCase (code .getPrettyName ())) {
575
+ for (SketchCode code : sketch .getCodes ()) {
576
+ if (!code .isPrimary () && newName .equalsIgnoreCase (code .getPrettyName ())) {
578
577
Base .showMessage (tr ("Error" ),
579
578
I18n .format (tr ("You can't save the sketch as \" {0}\" \n " +
580
579
"because the sketch already has a file with that name." ), newName
@@ -619,7 +618,7 @@ protected boolean saveAs() throws IOException {
619
618
620
619
// save the other tabs to their new location
621
620
for (SketchCode code : sketch .getCodes ()) {
622
- if (sketch . indexOfCode ( code ) == 0 ) continue ;
621
+ if (code . isPrimary () ) continue ;
623
622
File newFile = new File (newFolder , code .getFileName ());
624
623
code .saveAs (newFile );
625
624
}
0 commit comments