mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-16 03:40:36 +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 ifbegin} {$I ifbegin1.inc} {$ENDIF}
|
||||
{$IFDEF ifbeginelse} {$I ifbeginelse1.inc} {$ENDIF}
|
||||
{$IFDEF beginwithoutindent} {$I beginwithoutindent1.inc} {$ENDIF}
|
||||
|
||||
end.
|
||||
|
||||
@ -5254,13 +5254,22 @@ var
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
// use existing semicolon
|
||||
// replace trailing spaces
|
||||
while (ToPos<=SrcLen) and (Src[ToPos] in [' ',#9]) do inc(ToPos);
|
||||
// use existing semicolon
|
||||
if (NewCode[length(NewCode)]=';')
|
||||
and (ToPos<=SrcLen) and (Src[ToPos]=';') then begin
|
||||
AfterGap:=gtNone;
|
||||
inc(ToPos);
|
||||
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
|
||||
if FrontGap in [gtNone,gtSpace] then begin
|
||||
BeautifyFlags:=BeautifyFlags+[bcfDoNotIndentFirstLine];
|
||||
@ -5503,6 +5512,17 @@ var
|
||||
if not EndBlockIsOk then exit;
|
||||
BeginBlock(Stack,btCaseElse,CurPos.StartPos);
|
||||
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:
|
||||
begin
|
||||
// missing semicolon
|
||||
|
||||
Loading…
Reference in New Issue
Block a user