You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Gary Sheppard (Jira)" <ji...@apache.org> on 2020/06/26 15:30:00 UTC
[jira] [Created] (NETBEANS-4505) Strange formatting for try/catch
within switch
Gary Sheppard created NETBEANS-4505:
---------------------------------------
Summary: Strange formatting for try/catch within switch
Key: NETBEANS-4505
URL: https://issues.apache.org/jira/browse/NETBEANS-4505
Project: NetBeans
Issue Type: Bug
Components: java - Editor
Affects Versions: 12.0
Environment: Windows 10 Version 1803
Reporter: Gary Sheppard
Attachments: NetBeansFormatSwitchTryApp_caseIndent_correct.java, NetBeansFormatSwitchTryApp_caseIndent_formatted.java, NetBeansFormatSwitchTryApp_noCaseIndent_correct.java, NetBeansFormatSwitchTryApp_noCaseIndent_formatted.java
When I write a try/catch block inside a switch statement, and then I use Source > Format or Alt-Shift-F to format the code, the formatting seems wrong.
The behavior depends on whether Tools > Options > Editor > Formatting > Indent Case Statements in Switch is checked.
*If Indent Case Statements in Switch is checked*, I would expect formatting to look like this:
{code:java}
switch (val) {
case 0:
case 1:
try {
result = 42 / val;
} catch (ArithmeticException ex) {
System.out.println("You can't do that: " + ex.getMessage());
throw ex;
}
}{code}
Instead, the formatting looks like this:
{code:java}
switch (val) {
case 0:
case 1:
try {
result = 42 / val;
} catch (ArithmeticException ex) {
System.out.println("You can't do that: " + ex.getMessage());
throw ex;
}
}{code}
*If Indent Case Statements in Switch is not checked*, I would expect formatting to look like this:
{code:java}
switch (val) {
case 0:
case 1:
try {
result = 42 / val;
} catch (ArithmeticException ex) {
System.out.println("You can't do that: " + ex.getMessage());
throw ex;
}
}{code}
Instead, the formatting looks like this:
{code:java}
switch (val) {
case 0:
case 1:
try {
result = 42 / val;
} catch (ArithmeticException ex) {
System.out.println("You can't do that: " + ex.getMessage());
throw ex;
}
}{code}
I have attached complete Java source files that illustrate the behavior in both cases.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists