[Lazarus] Bug in cody. Exploding a hanging with block.

ListMember listmember at letterboxes.org
Sun Jun 8 23:29:28 CEST 2014


On 2014-06-08 23:14, Mattias Gaertner wrote:
> On Sun, 08 Jun 2014 21:50:17 +0300
> ListMember <listmember at letterboxes.org> wrote:
>
>> One thing I noticed is this: If the with block is more involved than a
>> simple element, such as this:
>>
>>         with Owner, FHeader, FFixedAreaConstraints, TreeView do begin
>>
>> you have to start 'exploding' from the right-most element and work your
>> way to the left-most one. Otherwise, the resulting code can become
>> meaningless/uncompilable.
> Yes. That's why the tool is in Cody and not in the standard IDE.

Could an alternative method of 'with explosion' be introduced so that 
when we place the cursor on the 'with' (rather than the element we want 
to explode away), cody decides on the best approach (i.e. start with the 
right-most one).

>> when I explode 'Items[FPositionToIndex[I]]' it becomes this:
>>
>> procedure TVirtualTreeColumns.UpdatePositions(Force: Boolean = False);
>> var
>>     I, RunningPos: Integer;
>> begin
>>     if not FNeedPositionsFix and (Force or (UpdateCount = 0)) then begin
>>       RunningPos := 0;
>> *for I := 0 to High(FPositionToIndex) do**
>> **      Items[FPositionToIndex[I]].FPosition := I;*
>>         Items[FPositionToIndex[I]].FLeft := RunningPos;
>>         if coVisible in Items[FPositionToIndex[I]].FOptions then
>> Inc(RunningPos, Items[FPositionToIndex[I]].FWidth);
>>     end;
>> end;
> Fixed.

Thank you.

Does that also apply to other forms of 'hanging with blocks' such as:

if something then
   with somethingelse begin
     {code}
   end;

If so, these 2 (including the right-most issue) should be the last one(s).

I can say that with some confidence because I have just finished getting 
rid of ALL 'with's from VirtualTrees.pas in less than half an hour.

And, it is all thanks to cody, because I have been trying (on and off) 
doing that for the last 6-7 years (became something of an obsession to me).

How I wish something like that was available for Delphi the 
paid-through-the-nose IDE..




More information about the Lazarus mailing list