From cbf974630b0ab83ca6ec23088c0ce4020c624cce Mon Sep 17 00:00:00 2001 From: George Bateman Date: Sat, 12 Dec 2015 14:37:42 +0000 Subject: [PATCH] Fix minor autoformatter bugs. Fixes #4185. Enums without semicolons and labels that aren't in a method body. --- java/src/processing/mode/java/AutoFormat.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/java/src/processing/mode/java/AutoFormat.java b/java/src/processing/mode/java/AutoFormat.java index f6d3d7252..ec61540dc 100644 --- a/java/src/processing/mode/java/AutoFormat.java +++ b/java/src/processing/mode/java/AutoFormat.java @@ -587,6 +587,7 @@ public class AutoFormat implements Formatter { break; } + // In a simple enum, there's not necessarily a `;` to end the statement. inStatementFlag = false; curlyLvl--; @@ -606,6 +607,7 @@ public class AutoFormat implements Formatter { trimRight(result); result.append('\n'); + overflowFlag = false; // Would normally be done in writeIndentedLine. printIndentation(); result.append(c); if (peek() == ';') result.append(nextChar()); @@ -728,10 +730,14 @@ public class AutoFormat implements Formatter { inStatementFlag = false; arrayLevel = -1; // Unlikely to be needed; just in case. - //Same format for case, default, and other labels. - tabs--; - writeIndentedLine(); - tabs++; + // Same format for case, default, and other labels. + if (tabs > 0) { + tabs--; + writeIndentedLine(); + tabs++; + } else { + writeIndentedLine(); + } readForNewLine(); writeIndentedLine();