diff --git a/app/src/processing/app/format/AutoFormat.java b/app/src/processing/app/format/AutoFormat.java index d075985b5..a92033d95 100644 --- a/app/src/processing/app/format/AutoFormat.java +++ b/app/src/processing/app/format/AutoFormat.java @@ -327,6 +327,7 @@ public class AutoFormat { case ',': trimRight(buf); buf.append(c); + buf.append(' '); break; case ' ': @@ -581,7 +582,7 @@ public class AutoFormat { if ((lookup("for"))) { c = get_string(); - while (c != ';') { + while (c != ';' && c != ':') { c = get_string(); } ct = 0; diff --git a/app/test/resources/bug420.expected b/app/test/resources/bug420.expected new file mode 100755 index 000000000..8ea69d2a7 --- /dev/null +++ b/app/test/resources/bug420.expected @@ -0,0 +1,6 @@ +int[] a = new int[] { + 1, 2, 3, 4, 5 +}; +for (int i: a) { + print(i); +} diff --git a/app/test/resources/bug420.pde b/app/test/resources/bug420.pde new file mode 100755 index 000000000..afeb1b991 --- /dev/null +++ b/app/test/resources/bug420.pde @@ -0,0 +1,2 @@ +int[] a = new int[] { 1,2,3,4,5 }; +for (int i: a) { print(i);} diff --git a/app/test/src/test/processing/parsing/AutoFormatTests.java b/app/test/src/test/processing/parsing/AutoFormatTests.java index a210dc64d..43b34fbf8 100644 --- a/app/test/src/test/processing/parsing/AutoFormatTests.java +++ b/app/test/src/test/processing/parsing/AutoFormatTests.java @@ -42,4 +42,9 @@ public class AutoFormatTests { public void bug109() { expectGood("bug109"); } + + @Test + public void bug420() { + expectGood("bug420"); + } }