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