mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-30 01:09:29 +02:00
codetools: fixed finding prior statement when start on source start
git-svn-id: trunk@18316 -
This commit is contained in:
parent
c2c0334f9f
commit
5d21138707
@ -2114,14 +2114,18 @@ begin
|
||||
// comment)
|
||||
TestPos:=Result-1;
|
||||
OnlySpace:=true;
|
||||
while (TestPos>SrcStart) do begin
|
||||
repeat
|
||||
if TestPos<=SrcStart then begin
|
||||
// no comment, the line end is really there :)
|
||||
exit;
|
||||
end;
|
||||
if (Source[TestPos]='/') and (Source[TestPos-1]='/') then begin
|
||||
// this is a comment line end -> search further
|
||||
while (TestPos>SrcStart) and (Source[TestPos]='/') do
|
||||
dec(TestPos);
|
||||
break;
|
||||
end else if Source[TestPos] in [#10,#13] then begin
|
||||
// no comment, the line end ist really there :)
|
||||
// no comment, the line end is really there :)
|
||||
exit;
|
||||
end else if OnlySpace
|
||||
and ((Source[TestPos]='}')
|
||||
@ -2132,7 +2136,7 @@ begin
|
||||
if (Source[Result]>' ') then OnlySpace:=false;
|
||||
dec(TestPos);
|
||||
end;
|
||||
end;
|
||||
until false;
|
||||
Result:=TestPos;
|
||||
end;
|
||||
|
||||
|
@ -2163,7 +2163,8 @@ begin
|
||||
if MainBeginNode=nil then exit;
|
||||
FromPos:=-1;
|
||||
if FindCreateFormStatement(MainBeginNode.StartPos,UpperCaseStr(AClassName),
|
||||
UpperCaseStr(AVarName),OldPosition)=-1 then begin
|
||||
UpperCaseStr(AVarName),OldPosition)=-1
|
||||
then begin
|
||||
// does not exist -> create as last in front of 'Application.Run'
|
||||
MoveCursorToCleanPos(MainBeginNode.StartPos);
|
||||
repeat
|
||||
@ -2291,6 +2292,7 @@ var Position, InsertPos, i, ColonPos, Indent: integer;
|
||||
StatementPos: TAtomPosition;
|
||||
MainBeginNode: TCodeTreeNode;
|
||||
AClassName, AVarName: string;
|
||||
LastEndPos: Integer;
|
||||
begin
|
||||
Result:= false;
|
||||
if (List = nil) or (SourceChangeCache = nil) then exit;
|
||||
@ -2298,23 +2300,29 @@ begin
|
||||
|
||||
{ first delete all CreateForm Statements }
|
||||
SourceChangeCache.MainScanner:= Scanner;
|
||||
MainBeginNode:= FindMainBeginEndNode;
|
||||
MainBeginNode:=FindMainBeginEndNode;
|
||||
if MainBeginNode = nil then exit;
|
||||
Position:= MainBeginNode.StartPos;
|
||||
InsertPos:= -1;
|
||||
Position:=MainBeginNode.StartPos;
|
||||
InsertPos:=-1;
|
||||
LastEndPos:=-1;
|
||||
repeat
|
||||
if FindCreateFormStatement(Position, '*', '*', StatementPos) = -1 then break;
|
||||
|
||||
Position:= StatementPos.EndPos;
|
||||
StatementPos.StartPos:= FindLineEndOrCodeInFrontOfPosition(StatementPos.StartPos);
|
||||
Position:=StatementPos.EndPos;
|
||||
StatementPos.StartPos:=FindLineEndOrCodeInFrontOfPosition(StatementPos.StartPos);
|
||||
if (LastEndPos>0) and (StatementPos.StartPos<LastEndPos) then
|
||||
StatementPos.StartPos:=LastEndPos;
|
||||
if InsertPos < 1 then InsertPos:= StatementPos.StartPos;
|
||||
|
||||
StatementPos.EndPos:= FindLineEndOrCodeAfterPosition(StatementPos.EndPos);
|
||||
StatementPos.EndPos:=FindLineEndOrCodeAfterPosition(StatementPos.EndPos);
|
||||
LastEndPos:=StatementPos.EndPos;
|
||||
|
||||
SourceChangeCache.Replace(gtNone,gtNone, StatementPos.StartPos, StatementPos.EndPos, '');
|
||||
if not SourceChangeCache.Replace(gtNone,gtNone, StatementPos.StartPos, StatementPos.EndPos, '') then
|
||||
exit;
|
||||
until false;
|
||||
|
||||
Result:= SourceChangeCache.Apply;
|
||||
Result:=SourceChangeCache.Apply;
|
||||
if not Result then exit;
|
||||
|
||||
{ then add all CreateForm Statements }
|
||||
if InsertPos < 1 then begin
|
||||
|
Loading…
Reference in New Issue
Block a user