mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-25 00:50:32 +01:00
codetools: complete block: do not add semicolon in front of an else, bug #14021
git-svn-id: trunk@20689 -
This commit is contained in:
parent
51d5f674d6
commit
d25179de98
@ -26,6 +26,7 @@ implementation
|
|||||||
{$IFDEF repeatifelse} {$I repeatifelse1.inc} {$ENDIF}
|
{$IFDEF repeatifelse} {$I repeatifelse1.inc} {$ENDIF}
|
||||||
|
|
||||||
{$IFDEF ifbegin} {$I ifbegin1.inc} {$ENDIF}
|
{$IFDEF ifbegin} {$I ifbegin1.inc} {$ENDIF}
|
||||||
|
{$IFDEF ifbeginelse} {$I ifbeginelse1.inc} {$ENDIF}
|
||||||
{$IFDEF beginwithoutindent} {$I beginwithoutindent1.inc} {$ENDIF}
|
{$IFDEF beginwithoutindent} {$I beginwithoutindent1.inc} {$ENDIF}
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
@ -5254,13 +5254,22 @@ var
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// use existing semicolon
|
// replace trailing spaces
|
||||||
while (ToPos<=SrcLen) and (Src[ToPos] in [' ',#9]) do inc(ToPos);
|
while (ToPos<=SrcLen) and (Src[ToPos] in [' ',#9]) do inc(ToPos);
|
||||||
|
// use existing semicolon
|
||||||
if (NewCode[length(NewCode)]=';')
|
if (NewCode[length(NewCode)]=';')
|
||||||
and (ToPos<=SrcLen) and (Src[ToPos]=';') then begin
|
and (ToPos<=SrcLen) and (Src[ToPos]=';') then begin
|
||||||
AfterGap:=gtNone;
|
AfterGap:=gtNone;
|
||||||
inc(ToPos);
|
inc(ToPos);
|
||||||
end;
|
end;
|
||||||
|
// use existing "else"
|
||||||
|
if (NewCode[length(NewCode)]=';') then begin
|
||||||
|
MoveCursorToCleanPos(ToPos);
|
||||||
|
ReadNextAtom;
|
||||||
|
if UpAtomIs('ELSE') then
|
||||||
|
NewCode:=copy(NewCode,1,length(NewCode)-1);
|
||||||
|
end;
|
||||||
|
|
||||||
// adjust indent of first line
|
// adjust indent of first line
|
||||||
if FrontGap in [gtNone,gtSpace] then begin
|
if FrontGap in [gtNone,gtSpace] then begin
|
||||||
BeautifyFlags:=BeautifyFlags+[bcfDoNotIndentFirstLine];
|
BeautifyFlags:=BeautifyFlags+[bcfDoNotIndentFirstLine];
|
||||||
@ -5503,6 +5512,17 @@ var
|
|||||||
if not EndBlockIsOk then exit;
|
if not EndBlockIsOk then exit;
|
||||||
BeginBlock(Stack,btCaseElse,CurPos.StartPos);
|
BeginBlock(Stack,btCaseElse,CurPos.StartPos);
|
||||||
end;
|
end;
|
||||||
|
btBegin:
|
||||||
|
begin
|
||||||
|
// missing end
|
||||||
|
if InCursorBlock then begin
|
||||||
|
{$IFDEF ShowCompleteBlock}
|
||||||
|
DebugLn(['ReadStatements NeedCompletion: unexpected else at ',CleanPosToStr(CurPos.StartPos),': missing end. block start: ',CleanPosToStr(Stack.Stack[Stack.Top].StartPos)]);
|
||||||
|
{$ENDIF}
|
||||||
|
NeedCompletion:=true;
|
||||||
|
end;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
btCaseColon,btRepeat:
|
btCaseColon,btRepeat:
|
||||||
begin
|
begin
|
||||||
// missing semicolon
|
// missing semicolon
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user