codetools: fixed FindLineEndOrCodeInFrontOfPosition stopping at empty lines

git-svn-id: trunk@24744 -
This commit is contained in:
mattias 2010-04-20 16:24:36 +00:00
parent cc036e53e9
commit bce545c4f8

View File

@ -2479,6 +2479,7 @@ var
CodePos: Integer; CodePos: Integer;
LineEndPos: LongInt; LineEndPos: LongInt;
LineStartPos: LongInt; LineStartPos: LongInt;
IsEmpty: Boolean;
begin begin
SrcStart:=MinPosition; SrcStart:=MinPosition;
if SrcStart<1 then SrcStart:=1; if SrcStart<1 then SrcStart:=1;
@ -2497,17 +2498,30 @@ begin
begin begin
// line end in code found // line end in code found
if (Result>SrcStart) and (Source[Result-1] in [#10,#13]) if (Result>SrcStart) and (Source[Result-1] in [#10,#13])
and (Source[Result]<>Source[Result-1]) then dec(Result); and (Source[Result]<>Source[Result-1]) then
dec(Result);
// test if it is a comment line (a line without code and at least one // test if it is a comment line (a line without code and at least one
// comment) // comment)
CodePos:=0; CodePos:=0;
LineEndPos:=Result; LineEndPos:=Result;
// go to line start // go to line start
TestPos:=Result; TestPos:=Result;
while (TestPos>SrcStart) and (not (Source[TestPos-1] in [#10,#13])) do IsEmpty:=true;
while (TestPos>SrcStart) do begin
case Source[TestPos-1] of
#10,#13: break;
' ',#9: ;
else IsEmpty:=false;
end;
dec(TestPos); dec(TestPos);
LineStartPos:=TestPos; end;
if IsEmpty then begin
// empty line
exit;
end;
// read line from start to end // read line from start to end
LineStartPos:=TestPos;
while TestPos<LineEndPos do begin while TestPos<LineEndPos do begin
case Source[TestPos] of case Source[TestPos] of
'{': '{':
@ -2567,7 +2581,7 @@ begin
end; end;
end; end;
if CodePos>0 then begin if CodePos>0 then begin
// there is code in the line // the line is not empty
Result:=CodePos+1; Result:=CodePos+1;
exit; exit;
end; end;