Skip to content

Fix #364 if-else autoformatting#2477

Merged
benfry merged 3 commits into
processing:masterfrom
AmnonOwed:Fix#364-AutoFormatIfElse
May 10, 2014
Merged

Fix #364 if-else autoformatting#2477
benfry merged 3 commits into
processing:masterfrom
AmnonOwed:Fix#364-AutoFormatIfElse

Conversation

@AmnonOwed

Copy link
Copy Markdown
Contributor

The auto-formatting of if-else statements, specifically the new line for else, has bugged me for a long time, but I always though this was the intended formatting style in Processing. Until I saw issue #364 today. So apparantly it is an issue, outstanding!

This pull request fixes the issue at hand, while having no impact on other auto-formatting results as different users have pointed out in issue #1791 in reply to an earlier - now revoked - fix by another user. All different code examples were extensively tested against both 2.1.2 and the patched code. Additional spaces and hard returns are also handled correctly by the patched code. Once again, the result is that the bug is fixed and no other auto-formatting results are impacted.

For a full comparison, see below:

Code examples that neither 2.1.2 or the patched code change after running auto-format:

INITIAL & AUTO-FORMATTED CODE:

if (true) background(0);
else if (true) background(0);

if (true) background(0); // comment
else if (true) background(0);

if (true) {
  background(0);
}
// comment
else if (true) {
  background(0);
}

Code examples that 2.1.2 and the patched code both change in the exact same way after running auto-format:

INITIAL CODE:

if (true) background(0); else if (true) background(0);

if (true) background(0); else background(0);

AUTO-FORMATTED CODE (both in 2.1.2 and the patched code):

if (true) background(0); 
else if (true) background(0);

if (true) background(0); 
else background(0);

Code examples that differ in how 2.1.2 and the patched code handle them:

INITIAL CODE:

if (true) {
  background(0);
} else {
  background(0);
}

if (true) { background(0); } else if (true) { background(0); }

AUTO-FORMATTED CODE (2.1.2):

if (true) {
  background(0);
} 
else {
  background(0);
}

if (true) { 
  background(0);
} 
else if (true) { 
  background(0);
}

AUTO-FORMATTED CODE (patched code):

if (true) {
  background(0);
} else {
  background(0);
}

if (true) { 
  background(0);
} else if (true) { 
  background(0);
}

For your consideration...

benfry added a commit that referenced this pull request May 10, 2014
@benfry benfry merged commit 267a366 into processing:master May 10, 2014
@benfry

benfry commented May 10, 2014

Copy link
Copy Markdown
Contributor

Fixes #364.

@AmnonOwed AmnonOwed deleted the Fix#364-AutoFormatIfElse branch May 11, 2014 08:46
@github-actions

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants