Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2024-10

Code formatter

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hi,

I've been playing with the code formatter.

If the 'Fix spacing' is checked, and 'Spaces around operators' is set to 'Never', the formatter nevertheless changes

lName:='';

to

lName := '';

Since the assignment operator is an operator, I expect it to leave the statement as it was.

Is this intentional, or is it a bug ?

From my debugging, I can say the following:

In SingleSpaceAfter it is hard-wired to have a space:

   SingleSpaceAfterTokens: TTokenTypeSet = [ttColon, ttAssign, ttComma,
     ttPlusAssign, ttMinusAssign, ttTimesAssign, ttFloatDivAssign];
   if (pt.TokenType in SingleSpaceAfterTokens) then
   begin
     lcPrev := pt.PriorSolidToken;
     if (lcPrev  nil) and (lcPrev.TokenType = ttDot) then // operaror  typename.:=( )  .+= .*=
       exit(false);
     exit(True);
   end;

Similarly, in SingleSpaceBefore, it is hard-wired to have a space:

   if (pt.TokenType in AssignmentDirectives) then
   begin
     lcPrev := pt.PriorSolidToken;
     if (lcPrev  nil) and (lcPrev.TokenType = ttDot) then // operaror  typename.:=( )
       exit(false);
     exit(True);
   end;

So, in my opinion, clearly a bug.

:= is an operator, and should therefor obey the setting for operators.

(or a separate setting is made for the assignment operator)

Yesterday's Lazarus.

Michael.

Reply by email