See this example below.
No configuration can solve this problem
The problem is that the Procedure "P_LoopActive" has no margins and is glued to the left
Procedure TForm_MenuPrincipal.P_ActiveUDPServer(Op: Integer);
Var PortaUDP: Integer;
Var fThread_UDPServer: TThread;
Begin
fThread_UDPServer := TThread.CreateAnonymousThread(Procedure
Procedure P_LoopAtive;
Var I: Integer;
Begin
PortaUDP := vPorta_Refresh;
For I := 1 To Count_SessionWindows Do Begin
Try
Server_Refresh.Active := False;
Server_Refresh.DefaultPort := PortaUDP;
Server_Refresh.BroadcastEnabled := True;
Server_Refresh.ThreadedEvent := False;
Server_Refresh.Active := True;
break;
Except
On E: Exception Do Begin // Não dar erro aleatorios no Terminal Server
Inc(PortaUDP);
FreeAndNil(Server_Refresh);
Server_Refresh := TIdUDPServer.Create(self);
Server_Refresh.OnUDPRead := Server_RefreshUDPRead;
P_LogException(E);
End;
End;
End;
End;
Begin
If Op = 0 Then
P_LoopAtive;
If Op = 1 Then Begin
Try
Server_Refresh.Active := True;
Except
P_LoopAtive;
End;
End;
End);
fThread_UDPServer.FreeOnTerminate := True;
fThread_UDPServer.Start;
End;
I see where the problem is: You have got an anonymous procedure with a nested procedure inside. The formatter does not support that yet. It does support anonymous procedures without that.
I wasn't even aware that the Compiler supports this kind of construct.
A simplified example would be:
which gets formatted as:
but should be formatted as:
Last edit: Thomas Mueller 2025-03-30
Added test cases for formatter unit tests in revision #4502 (still no fix, sorry. This is really complex.)
Fixed in revision #4965 (Actually fixed by Claude Code without breaking any of the other tests.)