Autoformatter: avoid code being left in buf

issue #2540
This commit is contained in:
GKFX
2014-06-04 16:21:02 +01:00
parent e86d7d1143
commit 2695fc55c3

View File

@@ -688,15 +688,10 @@ public class AutoFormat implements Formatter {
}
} // end switch
} // end while not EOF
if (buf.length() > 0) writeIndentedLine();
final String formatted = result.toString();
if (!formatted.replaceAll("[\\s\\*/]","")
.equals(source.replaceAll("[\\s\\*/]",""))) {
// Double-check - this thing's so buggy it might be best to have one.
throw new RuntimeException("The autoformatter did something funny. Please" +
"copy and paste your sketch into a new issue on GitHub. \n" +
"https://github.com/processing/processing/issues/new");
}
return formatted.equals(cleanText) ? source : formatted;
}
}