IDE: When completing a label, add a colon (':') after it. Issue #38307.

(cherry picked from commit 907f82485b)
This commit is contained in:
Juha 2021-09-27 20:34:43 +03:00 committed by Maxim Ganetsky
parent 4ea049265b
commit f2c26bd129

View File

@ -787,10 +787,10 @@ var
CanAddComma: Boolean; CanAddComma: Boolean;
ClassNode: TCodeTreeNode; ClassNode: TCodeTreeNode;
IsReadOnly: Boolean; IsReadOnly: Boolean;
Line: string; Line, s: string;
Indent: LongInt; Indent: LongInt;
StartContextPos: TCodeXYPosition; StartContextPos: TCodeXYPosition;
s: String; Dsc: TCodeTreeNodeDesc;
begin begin
Result:=''; Result:='';
CursorToLeft:=0; CursorToLeft:=0;
@ -966,18 +966,19 @@ begin
if CanAddSemicolon if CanAddSemicolon
and (not (ilcfNoEndSemicolon in IdentList.ContextFlags)) and (not (ilcfNoEndSemicolon in IdentList.ContextFlags))
then begin then begin
Dsc:=IdentItem.GetDesc;
if Dsc=ctnLabel then
Result+=':'
else
if (ilcfNeedsEndSemicolon in IdentList.ContextFlags) if (ilcfNeedsEndSemicolon in IdentList.ContextFlags)
or ((ilcfStartInStatement in IdentList.ContextFlags) or ((ilcfStartInStatement in IdentList.ContextFlags) and (Dsc=ctnProcedure))
and (IdentItem.GetDesc=ctnProcedure))
then begin then begin
Result+=';'; Result+=';';
if (CursorToLeft=0) and (IdentItem.GetDesc=ctnProcedure) if (CursorToLeft=0) and (Dsc=ctnProcedure) and (not IdentItem.IsFunction) then
and (not IdentItem.IsFunction) then begin begin
// a procedure call without parameters // a procedure call without parameters => put cursor behind semicolon
// => put cursor behind semicolon
end else begin end else begin
// keep cursor in front of semicolon inc(CursorToLeft); // keep cursor in front of semicolon
inc(CursorToLeft);
end; end;
end; end;
end; end;