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: (1 Total Rating)
4.00 out of 5
Total Votes: None
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;


  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  TMainForm = class(TForm)
    { Private declarations }
    procedure Batman;

  MainForm: TMainForm;


{$R *.dfm}

{ TMainForm }

procedure TMainForm.Batman;

  procedure Robin;




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.
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.

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 (
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:

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

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?

Pat Coffer at 10/21/2015 4:45:43 AM -
Still happening in Delphi 10 Seattle.  Very annoying.  Cannot use anonymous procedures at all.  Pressing <Enter> anywhere in the unit below the "begin" of an anonymous procedure causes block completion to insert an "end;" that does not belong.

TomᚠBöhm at 1/15/2016 6:10:07 AM -
Same with Seattle 10 Update 1. Block completion works, if the anonymous procedure has a blank parentheses:

Server Response from: ETNACODE01