Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.

Public Report
Report From: C++BuilderX/IDE/Code Editor/Format    [ Add a report in this area ]  
Report #:  7119   Status: Reported
Wrapping of long lines not handled correct when Formatting
Project:  C++BuilderX/BC++ 2005 Build #:  1786
Version:    1.0 Submitted By:   Andre Truter
Report Type:  Minor failure / Design problem Date Reported:  1/30/2004 12:03:20 AM
Severity:    Commonly encountered problem Last Updated:
Platform:    All platforms Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: None
Description
When wrapping long lines, it only wraps it correct the first time, on the next format, it will un-indent the wrapped line.

It also indents the brackets when the line above it has been wrapped.
Steps to Reproduce:
Formatting settings:
Block indent: 2
Continuation indent: 4
Uncheck 'Use tab char'
General indentation style: Body only
Wrapping: Indentation: Break at column: 80

Create a source file that contain long lines.
One function for example:

int testFunction3( int number1, int number2, int number3, int number4 )
{
  if ( ( testFunction2( number1, number2, number3, number4 ) +  testFunction1( number1, number2, number3, number4 ) ) > 100 )
  {
    if ( testFunction2( number1, number2, number3, number4 ) > 10 )
    {
      return 1;
    }
  }
}

Now right-click and format.
Function is changed like this:

int testFunction3( int number1, int number2, int number3, int number4 )
{
  if ( ( testFunction2( number1, number2, number3, number4 ) +
       testFunction1( number1, number2, number3, number4 ) ) > 100 )
       {
         if ( testFunction2( number1, number2, number3, number4 ) > 10 )
         {
           return 1;
         }
  }
}

Note that the wrapping and continuation is done correctly, but the opening bracket of teh first if is indented, while the closing bracket is not.
(This is on Linux, on Windows, both opening and closing braces are indented with the continuation)

Now right-click and format again.
The function is changed again:

int testFunction3( int number1, int number2, int number3, int number4 )
{
  if ( ( testFunction2( number1, number2, number3, number4 ) +
  testFunction1( number1, number2, number3, number4 ) ) > 100 )
  {
    if ( testFunction2( number1, number2, number3, number4 ) > 10 )
    {
      return 1;
    }
  }
}

This time the braces are aligned correct, but the continuation indentation is lost.

This is what I would expect it to look with the formatting settings:

int testFunction3( int number1, int number2, int number3, int number4 )
{
  if ( ( testFunction2( number1, number2, number3, number4 ) +
      testFunction1( number1, number2, number3, number4 ) ) > 100 )
  {
    if ( testFunction2( number1, number2, number3, number4 ) > 10 )
    {
      return 1;
    }
  }
}
Workarounds
Don't use automatic Formatting...
Attachment
None
Comments

None

Server Response from: ETNACODE01