From f2c26bd129ff617dd5ca461495eccc3978ddad1a Mon Sep 17 00:00:00 2001 From: Juha Date: Mon, 27 Sep 2021 20:34:43 +0300 Subject: [PATCH] IDE: When completing a label, add a colon (':') after it. Issue #38307. (cherry picked from commit 907f82485b64a958e65b472d1d9ed3e420c32558) --- ide/sourceeditprocs.pas | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ide/sourceeditprocs.pas b/ide/sourceeditprocs.pas index 25ff97fba9..85530f3987 100644 --- a/ide/sourceeditprocs.pas +++ b/ide/sourceeditprocs.pas @@ -787,10 +787,10 @@ var CanAddComma: Boolean; ClassNode: TCodeTreeNode; IsReadOnly: Boolean; - Line: string; + Line, s: string; Indent: LongInt; StartContextPos: TCodeXYPosition; - s: String; + Dsc: TCodeTreeNodeDesc; begin Result:=''; CursorToLeft:=0; @@ -966,18 +966,19 @@ begin if CanAddSemicolon and (not (ilcfNoEndSemicolon in IdentList.ContextFlags)) then begin + Dsc:=IdentItem.GetDesc; + if Dsc=ctnLabel then + Result+=':' + else if (ilcfNeedsEndSemicolon in IdentList.ContextFlags) - or ((ilcfStartInStatement in IdentList.ContextFlags) - and (IdentItem.GetDesc=ctnProcedure)) + or ((ilcfStartInStatement in IdentList.ContextFlags) and (Dsc=ctnProcedure)) then begin Result+=';'; - if (CursorToLeft=0) and (IdentItem.GetDesc=ctnProcedure) - and (not IdentItem.IsFunction) then begin - // a procedure call without parameters - // => put cursor behind semicolon + if (CursorToLeft=0) and (Dsc=ctnProcedure) and (not IdentItem.IsFunction) then + begin + // a procedure call without parameters => put cursor behind semicolon end else begin - // keep cursor in front of semicolon - inc(CursorToLeft); + inc(CursorToLeft); // keep cursor in front of semicolon end; end; end;