mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-05 13:39:39 +01:00
codetools: fixed FindLineEndOrCodeInFrontOfPosition stopping at empty lines
git-svn-id: trunk@24744 -
This commit is contained in:
parent
cc036e53e9
commit
bce545c4f8
@ -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;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user