Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343316 - line wrapping misbehaves inside switch statements
Summary: line wrapping misbehaves inside switch statements
Status: RESOLVED WORKSFORME
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 7.0.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Anton Leherbauer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-19 17:21 EDT by Maynard Johnson CLA
Modified: 2011-05-16 03:43 EDT (History)
2 users (show)

See Also:


Attachments
Eclipse/CDT formatter (15.99 KB, text/xml)
2011-04-19 17:21 EDT, Maynard Johnson CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.