Bug 109 : Auto Format removing code near extra braces or parens
Last modified: 2010-03-26 07:05



Assigned To:

Attachment Type Created Size Actions

Description:   Opened: 2005-07-28 05:32
reported by dr_tectonic:

I have found what seems to be an error in the auto-format tool's behavior.
If I have code that looks like the following:

class Bug{
w = random(size)/3)+10;

and I run auto-format, it deletes everything in the sketch after the paren
following the 3. Which seems very much the wrong thing to do.

I think it's because this code is wrong (extra paren; should be
"random(size/3)+10"), so it's mis-parsing in some way. If you hit "undo",
you get a blank sketch (everything deleted); a second "undo" gets you back
to where you were before you ran auto-format.

I'm running 0.90 on a win2k box, but I'm pretty sure it did the same thing
on my linux box at work.
Additional Comment #1 From fry 2005-07-28 05:33
in the meantime just undo (may need to more than once). the auto-format
code is contributed from martin gomez so he's in charge of fixing it. but
if he can't fix it then we'll just go back to the old formatter.
Additional Comment #2 From st33d 2005-10-19 11:49
I was trying to isolate the bug which causes the auto format delete when I
found this little number

void setup(){
void draw(){

Copy the code into Processing and auto-format it. It's funny what happens.

Similarly auto-delete occurs without the comment. Observe the following:

void setup(){
void draw(){

So it seems to be reacting to the brackets.
Additional Comment #3 From fry 2005-12-01 06:59
the initial report is the same issues as bug #110 (which is now fixed). the
latter part, about the "e" repeating itself after an autoformat is what
this bug now covers.

removing the comment on the last line seems to just remove the line

also there needs to be no newline character at the end of the code.
martin's autoformatter seems to assume that there will always be a newline,
which is often not the case.
Additional Comment #4 From fry 2005-12-01 09:04
getting closer... the "whee" issue is now fixed for 0098, but the final

void setup(){
void draw(){

remains a problem, that "Goodbye" is removed.

may also be related to bug #235.
Additional Comment #5 From fry 2006-03-08 19:55
*** Bug 304 has been marked as a duplicate of this bug. ***