mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-01 12:23:42 +02:00
SynEdit IFDEF: fix crash with elseif
git-svn-id: trunk@41821 -
This commit is contained in:
parent
d3184470ed
commit
db3fc39cbd
@ -1877,7 +1877,11 @@ begin
|
|||||||
// idnEndIf: if PeerList[i].ElsePeer <> nil then continue;
|
// idnEndIf: if PeerList[i].ElsePeer <> nil then continue;
|
||||||
//end;
|
//end;
|
||||||
|
|
||||||
if (PeerList[i].NodeType = idnElse) and (AOuterLines <> nil) then begin
|
assert(not (PeerList[i].NodeType in [idnIfdef, idnCommentedNode]), 'multi-line peer valid');
|
||||||
|
//if (PeerList[i].NodeType = idnElse) and (AOuterLines <> nil) then begin
|
||||||
|
if (AOuterLines <> nil) then begin
|
||||||
|
// todo: find multiply elseif
|
||||||
|
assert((PeerList[i].NodeType in [idnElse, idnElseIf]), 'multi-line (opening) peer valid');
|
||||||
// scanning outer lines
|
// scanning outer lines
|
||||||
j := ToPos(AOuterLines.NodeLineEx[i-1, 1]);
|
j := ToPos(AOuterLines.NodeLineEx[i-1, 1]);
|
||||||
if j < 0 then begin
|
if j < 0 then begin
|
||||||
|
@ -55,6 +55,7 @@ type
|
|||||||
function TestText6: TStringArray;
|
function TestText6: TStringArray;
|
||||||
function TestText7: TStringArray;
|
function TestText7: TStringArray;
|
||||||
function TestText8: TStringArray;
|
function TestText8: TStringArray;
|
||||||
|
function TestText9: TStringArray;
|
||||||
|
|
||||||
procedure CheckOpenCloseCount(AName: String; ALine: Integer;
|
procedure CheckOpenCloseCount(AName: String; ALine: Integer;
|
||||||
AExpOpenCnt, AExpCloseCnt: Integer);
|
AExpOpenCnt, AExpCloseCnt: Integer);
|
||||||
@ -618,6 +619,40 @@ begin
|
|||||||
AddLine('' );
|
AddLine('' );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TTestMarkupIfDef.TestText9: 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('{$Elseif}' );
|
||||||
|
// 5
|
||||||
|
AddLine('' );
|
||||||
|
AddLine('{$Elseif}' );
|
||||||
|
AddLine('' );
|
||||||
|
AddLine('' );
|
||||||
|
AddLine('{$Elseif}' );
|
||||||
|
// 10
|
||||||
|
AddLine('' );
|
||||||
|
AddLine('' );
|
||||||
|
AddLine(' {$IFDEF b}' );
|
||||||
|
AddLine('' );
|
||||||
|
AddLine(' {$Endif}' );
|
||||||
|
// 15
|
||||||
|
AddLine('' );
|
||||||
|
AddLine('' );
|
||||||
|
AddLine('{$Endif}' );
|
||||||
|
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
|
||||||
@ -1907,16 +1942,17 @@ procedure TTestMarkupIfDef.TestIfDefTreePeerConnect;
|
|||||||
|
|
||||||
{%region }
|
{%region }
|
||||||
n := 'scan new unfinished node, next node will be comment';
|
n := 'scan new unfinished node, next node will be comment';
|
||||||
ReCreateEditForTreeTest(TestText4);
|
ReCreateEditForTreeTest(TestText9);
|
||||||
FTestTree.ValidateRange(1, 6, 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) ]);
|
||||||
CheckNodes(n, 4, [ ExpN( 1,11, idnIfdef), ExpN(13,21, idnEndIf) ]);
|
|
||||||
|
|
||||||
|
n := 'scan new unfinished node, next node will be comment';
|
||||||
|
ReCreateEditForTreeTest(TestText9);
|
||||||
|
FTestTree.ValidateRange(11, 18, FOpenings);
|
||||||
|
//CheckNodes(n, 2, [ ExpN( 1,11, idnIfdef), ExpN(13,21, idnEndIf) ]);
|
||||||
|
|
||||||
SynEdit.TextBetweenPoints[point(1, 3),point(1, 3)] := ' {$IFDEF ';
|
|
||||||
FTestTree.ValidateRange(1, 6, FOpenings);
|
|
||||||
|
|
||||||
CheckNodes(n, 2, [ ExpN( 1,11, idnIfdef), ExpN(13,21, idnEndIf) ]);
|
|
||||||
// CheckNodes(n, 3, [ ExpN( 1,1, 3, idnIfdef) ]);
|
|
||||||
{%endregion }
|
{%endregion }
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user