Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 343316

Summary: line wrapping misbehaves inside switch statements
Product: [Tools] CDT Reporter: Maynard Johnson <maynardj>
Component: cdt-editorAssignee: Project Inbox <cdt-editor-inbox>
Status: RESOLVED WORKSFORME QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, yevshif
Version: 7.0.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Eclipse/CDT formatter none

Description Maynard Johnson CLA 2011-04-19 17:21:24 EDT
Created attachment 193625 [details]
Eclipse/CDT formatter

I'm using CDT on a project where much of the heavy-duty coding is done inside switch statements. The code lines are often very long, so I need intelligent line wrapping to make the code readable. Unfortunately, there seems to be a bug (unless I'm missing something) in the way that line wrapping behaves inside switch statements.

I'm using a project-specific formatter that I created that sets line wrapping for function calls thusly:
    Line wrapping policy:
     Wrap all elements, except first element if not necessary

    Indentation policy:
     Indent on column

Below is a simple snippet of code, formatted with my project-specific formatter (attached), that demonstrates the problem. Note that for the wrapped statement outside of the switch statement, the second line aligns where you would expect it to -- directly under the first function argument in the line above. Then note that for the wrapped line within the switch statement, the second line is offset 3 spaces to the left of where it "should" be.

-------------------------
int main(void)
{
   int c;
   assign( hiResult,
           unop( Iop_ReinterpF64asI64,
                 binop( Iop_AddF64, mkexpr( frA ), mkexpr( frB ) ) ) );
   switch (c) {
      case 0:
         assign( hiResult,
              unop( Iop_ReinterpF64asI64,
                    binop( Iop_AddF64, mkexpr( frA ), mkexpr( frB ) ) ) );
         break;
      default:
         printf("not found");
   }
   return;
}
--------------------------
Comment 1 Anton Leherbauer CLA 2011-05-16 03:43:11 EDT
This seems to work for me with 7.0.2 and HEAD.
Maybe you need to provide a more complete source sample.