Jump to content
Registration disabled at the moment Read more... ×
Miko330

Problem indent with inline var inside try/finally

Recommended Posts

try
   var a := 2;

   test(a);

finally
end;

 

becomes :

try
var a:=2;

   test(a);

finally
end;

 

I don't know if this is the right method:

after adding 2 lines in 'GX_CodeFormatterFormatter.pas' at line 1633

-------------------------------------------------------------------------

             end else if (FPrevToken.GetExpression(exp) and SameText(exp, 'for')) then begin
               // for with inline var declaration
             end else if (fStack.GetTopType = rtTry) then begin
               // inline var declaration inside Try/finally block

             end else begin

---------------------------------------------------------------------------

everything becomes good with the right indentation inside Try/Finally.

 

Edited by Miko330

Share this post


Link to post

Does this also apply to inline variables inside begin/end blocks or only to try..except/finally blocks?

Share this post


Link to post
1 hour ago, Miko330 said:

try
   var a := 2;
   test(a);
finally
end;

becomes :


try
var a:=2;
   test(a);
finally
end;

I don't know if this is the right method:

after adding 2 lines in 'GX_CodeFormatterFormatter.pas' at line 1633

-------------------------------------------------------------------------


             end else if (FPrevToken.GetExpression(exp) and SameText(exp, 'for')) then begin
               // for with inline var declaration
             end else if (fStack.GetTopType = rtTry) then begin
               // inline var declaration inside Try/finally block
             end else begin

---------------------------------------------------------------------------

everything becomes good with the right indentation inside Try/Finally.

 

Just to confirm: Your first example is how you think it should be formatted?

Share this post


Link to post

The inline var line is not indented.

 

what i want :

 

try
   var a := 2;
   test(a);
finally
end;

and the formatter gives me this

 

try
var a:=2;
   test(a);
finally
end;

Share this post


Link to post
On 11/24/2023 at 1:02 PM, baka0815 said:

Does this also apply to inline variables inside begin/end blocks or only to try..except/finally blocks?

Inline variable declarations in begin end blocks already worked fine.

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×