Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Block Completion    [ Add a report in this area ]  
Report #:  97844   Status: Open
Block completion fails after local procedures
Project:  Delphi Build #:  15.0.3953.35171
Version:    15.1 Submitted By:   Márton Balassa
Report Type:  Basic functionality failure Date Reported:  8/19/2011 4:21:44 AM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   286750
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Using local procedures inside methods make block completion stop working after the end of the local procedure. See steps.
Steps to Reproduce:
1. Create new VCL Forms application.
2. Declare a method in the form:

--------------------------------------------------------------------------------
unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TMainForm = class(TForm)
  private
    { Private declarations }
  public
    procedure Batman;
  end;

var
  MainForm: TMainForm;

implementation

{$R *.dfm}

{ TMainForm }

procedure TMainForm.Batman;

  procedure Robin;
  begin

  end;

begin
  try|
end;

end.
--------------------------------------------------------------------------------

3. Declare a local procedure inside the method.
4. Place the cursor after 'try' (marked by the pipe character) and press ENTER.

Expected: the try-finally-end block is automatically created.
Actual: nothing happens, and block completion doesn't work for the rest of the method.
Block completion resumes working instantly if you remove the local procedure.
Workarounds
Avoid using local procedures when encountering this problem. In some cases, block completion will not break due to local procedures, but the above steps can reproduce the problem.
Attachment
BlockFail2.zip
Comments

Márton Balassa at 10/13/2011 2:49:29 AM -
In many cases, declaring anonymous methods break block completion as well, but I can't provide a simple test case yet.

Márton Balassa at 10/14/2011 4:53:18 AM -
Update! I've assembled a demo showing even weirder editor behavior. See attachment (BlockFail2.zip).
Note that this is a minimal test case. In our projects, we managed to create anonymous methods that screw up block completion so badly that after pressing enter ANYWHERE in the file, the editor inserts a closing for some previous block, producing code like this:

    begin
      // even Chuck Norris can't press enter anywhere near without inserting another 'end' line.
    end;
    end;
    end;
    end;

All our source files compile and run perfectly of course, this is merely an editor bug.

One more comment for Embarcadero: beacuse these errors, our productivity has dropped seriously after migrating our projects from D2007 to XE. We are forced to continous refactoring and anti-optimization. This not only takes time for developers, but also makes our software slower and more complicated, since we can't use anonymous methods and/or local procedures on many occasions. Will you consider this a show stopper? Will you fix this bug in XE?

Server Response from: ETNACODE01