Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Code Templates    [ Add a report in this area ]  
Report #:  21276   Status: Open
Surrounds function not indenting properly
Project:  Delphi Build #:  10.0.2137.22690
Version:    10.0 Submitted By:   Bob Fisher
Report Type:  Basic functionality failure Date Reported:  11/10/2005 10:51:56 PM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   236119
Resolution: Deferred to Next Rel (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (2 Total Ratings)
4.00 out of 5
Total Votes: 6
Description
When using the "Surround" function, the resulting code does not get indented properly.
Steps to Reproduce:
Given the following routine:

procedure TForm1.Button1Click(Sender: TObject);
var
  k: integer;
  s: TObject;
begin

  for k:= 0 to 100 do
  begin
    // create something
    s:= TObject.Create;
    // use the object
    label1.caption:= s.ClassName;
  end;

end;

Mark the two lines:
    // use the object
    label1.caption:= s.ClassName;

Choose, Surround | tryf

The result is:

procedure TForm1.Button1Click(Sender: TObject);
var
  k: integer;
  s: TObject;
begin

  for k:= 0 to 100 do
  begin
    // create something
    s:= TObject.Create;

try
      // use the object
      label1.caption:= s.ClassName;

finally
end;  end;

end;

As you can see, the resulting code is not indented or formatted properly.  
Workarounds
None
Attachment
None
Comments

Alistair Ward at 12/14/2005 8:51:33 PM -
If you select whole lines (ie the selected block starts at column 1), and say surround, then the surrounding code (the try/finally) is placed at column 1, and the surrounded code is indented.

If you start your selection from the first non-space character of the lines you want to indent (eg column 5), then the try is indented with the surrounded code, but at least the finally is put in the correct column.

Server Response from: ETNACODE01