mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-16 09:29:35 +01:00
SynEdit IFDEF: fix crash with comments
git-svn-id: trunk@41847 -
This commit is contained in:
parent
e02311e159
commit
c692aea81a
@ -2856,6 +2856,9 @@ XXXCurTree := self; try
|
|||||||
Assert(TmpNode.HasNode, 'TmpNode.HasNode');
|
Assert(TmpNode.HasNode, 'TmpNode.HasNode');
|
||||||
Assert(NextNode.EntryCount > 0, 'NextNode.EntryCount > 0');
|
Assert(NextNode.EntryCount > 0, 'NextNode.EntryCount > 0');
|
||||||
Node := TmpNode;
|
Node := TmpNode;
|
||||||
|
CheckNextNodeForEmpty(NextNode, Node.LastEntryEndLine);
|
||||||
|
if not NextNode.HasNode then
|
||||||
|
break;
|
||||||
TmpNode.ClearInfo;
|
TmpNode.ClearInfo;
|
||||||
while Node.ScanEndLine + 1 < NextNode.StartLine do begin
|
while Node.ScanEndLine + 1 < NextNode.StartLine do begin
|
||||||
MaybeExtendNodeForward(Node, TmpNode, NextNode.StartLine);
|
MaybeExtendNodeForward(Node, TmpNode, NextNode.StartLine);
|
||||||
|
|||||||
@ -56,6 +56,7 @@ type
|
|||||||
function TestText7: TStringArray;
|
function TestText7: TStringArray;
|
||||||
function TestText8: TStringArray;
|
function TestText8: TStringArray;
|
||||||
function TestText9: TStringArray;
|
function TestText9: TStringArray;
|
||||||
|
function TestText10: TStringArray;
|
||||||
|
|
||||||
procedure CheckOpenCloseCount(AName: String; ALine: Integer;
|
procedure CheckOpenCloseCount(AName: String; ALine: Integer;
|
||||||
AExpOpenCnt, AExpCloseCnt: Integer);
|
AExpOpenCnt, AExpCloseCnt: Integer);
|
||||||
@ -653,6 +654,26 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TTestMarkupIfDef.TestText10: TStringArray;
|
||||||
|
procedure AddLine(s: String);
|
||||||
|
begin
|
||||||
|
SetLength(Result, Length(Result)+1);
|
||||||
|
Result[Length(Result)-1] := s;
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
// 1
|
||||||
|
AddLine('//' );
|
||||||
|
AddLine('{$IFDEF a}' );
|
||||||
|
AddLine('' );
|
||||||
|
AddLine('' );
|
||||||
|
// 5
|
||||||
|
AddLine('' );
|
||||||
|
AddLine('' );
|
||||||
|
AddLine('{$IFDEF a}' );
|
||||||
|
AddLine('//' );
|
||||||
|
AddLine('' );
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestMarkupIfDef.CheckOpenCloseCount(AName: String; ALine: Integer; AExpOpenCnt,
|
procedure TTestMarkupIfDef.CheckOpenCloseCount(AName: String; ALine: Integer; AExpOpenCnt,
|
||||||
AExpCloseCnt: Integer);
|
AExpCloseCnt: Integer);
|
||||||
var
|
var
|
||||||
@ -1941,13 +1962,13 @@ procedure TTestMarkupIfDef.TestIfDefTreePeerConnect;
|
|||||||
{%endregion }
|
{%endregion }
|
||||||
|
|
||||||
{%region }
|
{%region }
|
||||||
n := 'scan new unfinished node, next node will be comment';
|
n := 'multi elseif open';
|
||||||
ReCreateEditForTreeTest(TestText9);
|
ReCreateEditForTreeTest(TestText9);
|
||||||
FTestTree.ValidateRange(1, 18, FOpenings);
|
FTestTree.ValidateRange(1, 18, FOpenings);
|
||||||
//CheckNodes(n, 2, [ ExpN( 1,11, idnIfdef), ExpN(13,21, idnEndIf) ]);
|
//CheckNodes(n, 2, [ ExpN( 1,11, idnIfdef), ExpN(13,21, idnEndIf) ]);
|
||||||
|
|
||||||
|
|
||||||
n := 'scan new unfinished node, next node will be comment';
|
//n := '';
|
||||||
ReCreateEditForTreeTest(TestText9);
|
ReCreateEditForTreeTest(TestText9);
|
||||||
FTestTree.ValidateRange(11, 18, FOpenings);
|
FTestTree.ValidateRange(11, 18, FOpenings);
|
||||||
//CheckNodes(n, 2, [ ExpN( 1,11, idnIfdef), ExpN(13,21, idnEndIf) ]);
|
//CheckNodes(n, 2, [ ExpN( 1,11, idnIfdef), ExpN(13,21, idnEndIf) ]);
|
||||||
@ -1957,6 +1978,26 @@ procedure TTestMarkupIfDef.TestIfDefTreePeerConnect;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{%region }
|
||||||
|
n := '';
|
||||||
|
ReCreateEditForTreeTest(TestText10);
|
||||||
|
FTestTree.ValidateRange(1, 9, FOpenings);
|
||||||
|
FTestTree.SetNodeState(7, 1, idnDisabled);
|
||||||
|
//CheckNodes(n, 2, [ ExpN( 1,11, idnIfdef), ExpN(13,21, idnEndIf) ]);
|
||||||
|
|
||||||
|
SynEdit.TextBetweenPoints[point(1, 4),point(1, 4)] := '{$endi';
|
||||||
|
FTestTree.ValidateRange(1, 9, FOpenings);
|
||||||
|
|
||||||
|
SynEdit.TextBetweenPoints[point(7, 4),point(7, 4)] := 'f';
|
||||||
|
FTestTree.ValidateRange(1, 9, FOpenings);
|
||||||
|
|
||||||
|
SynEdit.TextBetweenPoints[point(12, 4),point(12, 4)] := '} ';
|
||||||
|
FTestTree.ValidateRange(1, 9, FOpenings);
|
||||||
|
|
||||||
|
|
||||||
|
{%endregion }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FTestTree.DiscardOpeningList(FOpenings);
|
FTestTree.DiscardOpeningList(FOpenings);
|
||||||
FOpenings := nil;
|
FOpenings := nil;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user