From 57c88852ab7421fba6adeeecec5f81a6df002534 Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 16 Apr 2022 13:08:03 +0200 Subject: [PATCH] codetools: fixed complete event assignment keeping spaces after assign operator --- components/codetools/codecompletiontool.pas | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index 84b3f4e331..00fed4f2cc 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -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;