codetools: fixed complete event assignment keeping spaces after assign operator

This commit is contained in:
mattias 2022-04-16 13:08:03 +02:00
parent 87bcd888ad
commit 57c88852ab

View File

@ -2155,14 +2155,30 @@ function TCodeCompletionCodeTool.CompleteEventAssignment(CleanCursorPos,
{$ENDIF}
// add new event name as right value of assignment
// add address operator @ if needed or user provided it himself
if UserEventAtom.StartPos>0 then begin
end else begin
end;
RValue:=AnEventName+';';
if (AddrOperatorPos>0)
or ((Scanner.PascalCompiler=pcFPC) and (Scanner.CompilerMode<>cmDelphi))
or (Scanner.CompilerMode in [cmDelphi,cmDELPHIUNICODE])
then
RValue:='@'+RValue;
RValue:=':='+RValue;
if (AddrOperatorPos>0) or (UserEventAtom.StartPos>0) then begin
// left := |SomeName -> keep assignment and space behind
StartInsertPos:=AddrOperatorPos;
if StartInsertPos<1 then
StartInsertPos:=UserEventAtom.StartPos;
end else begin
// left :=|
RValue:=':='+RValue;
StartInsertPos:=AssignmentOperator;
end;
RValue:=SourceChangeCache.BeautifyCodeOptions.BeautifyStatement(RValue,0);
StartInsertPos:=AssignmentOperator;
RValue:=TrimLeft(RValue);
EndInsertPos:=SemicolonPos+1;
if EndInsertPos<1 then
EndInsertPos:=UserEventAtom.EndPos;