You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Fernando Scherrer (Jira)" <ji...@apache.org> on 2020/10/18 19:45:00 UTC

[jira] [Commented] (NETBEANS-4505) Strange formatting for try/catch within switch

    [ https://issues.apache.org/jira/browse/NETBEANS-4505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17216360#comment-17216360 ] 

Fernando Scherrer commented on NETBEANS-4505:
---------------------------------------------

As a work around, I reverted [this change|https://github.com/apache/netbeans/commit/eb9f15df149411f287988fde63da54a9b059095c#diff-a5309f14f4ad89d39d71d17b338d293b44eb85812421f507717ff5ba61c95839R4289].

> 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
>            Priority: Trivial
>         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