mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-18 10:49:27 +02:00
SynEdit: Fixed issue in IFDEF code (re-using commented node)
git-svn-id: trunk@42487 -
This commit is contained in:
parent
03d18a15a7
commit
acfad58d98
@ -895,7 +895,7 @@ end;
|
||||
|
||||
function TSynMarkupHighIfDefEntry.UncommentedNodeType: TSynMarkupIfdefNodeType;
|
||||
begin
|
||||
Result := NodeType;
|
||||
Result := FNodeType;
|
||||
end;
|
||||
|
||||
procedure TSynMarkupHighIfDefEntry.MakeCommented;
|
||||
@ -1274,7 +1274,9 @@ end;
|
||||
procedure TSynMarkupHighIfDefEntry.ClearAll;
|
||||
begin
|
||||
ClearPeers;
|
||||
RemoveNodeStateFromLine;
|
||||
FNodeFlags := [];
|
||||
ApplyNodeStateToLine;
|
||||
end;
|
||||
|
||||
{ TSynMarkupHighIfDefLinesNode }
|
||||
@ -2044,6 +2046,8 @@ var
|
||||
|
||||
begin
|
||||
// Line nodes vill be invalidated in DoHighlightChanged
|
||||
XXXCurTree := self; try
|
||||
|
||||
IncChangeStep;
|
||||
|
||||
if aLineBrkCnt > 0 then begin
|
||||
@ -2248,6 +2252,7 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
finally XXXCurTree := nil; end;
|
||||
end;
|
||||
|
||||
procedure TSynMarkupHighIfDefLinesTree.DoHighlightChanged(Sender: TSynEditStrings; AIndex,
|
||||
|
@ -57,6 +57,7 @@ type
|
||||
function TestText8: TStringArray;
|
||||
function TestText9: TStringArray;
|
||||
function TestText10: TStringArray;
|
||||
function TestText11: TStringArray;
|
||||
|
||||
procedure CheckOpenCloseCount(AName: String; ALine: Integer;
|
||||
AExpOpenCnt, AExpCloseCnt: Integer);
|
||||
@ -674,6 +675,36 @@ begin
|
||||
AddLine('' );
|
||||
end;
|
||||
|
||||
function TTestMarkupIfDef.TestText11: TStringArray;
|
||||
procedure AddLine(s: String);
|
||||
begin
|
||||
SetLength(Result, Length(Result)+1);
|
||||
Result[Length(Result)-1] := s;
|
||||
end;
|
||||
begin
|
||||
// 1
|
||||
AddLine('//' );
|
||||
AddLine(' {$if defined(cpu86)} ');
|
||||
AddLine(' // a');
|
||||
AddLine(' {$elseif defined(cpupowerpc)} ');
|
||||
//5
|
||||
AddLine(' // disabled ');
|
||||
AddLine(' {$elseif defined(cpupowerpc)} ');
|
||||
AddLine(' // enabled (invalid) ');
|
||||
AddLine(' {$elseif defined(cpuarm)} ');
|
||||
AddLine(' // enabled (invalid) ');
|
||||
// 10
|
||||
AddLine(' {$elseif defined(CPUX86_64)} ');
|
||||
AddLine(' // enabled (invalid) ');
|
||||
AddLine(' {$else} ');
|
||||
AddLine(' // enabled (invalid) ');
|
||||
AddLine(' {$ifend} ');
|
||||
//16
|
||||
AddLine('' );
|
||||
AddLine('' );
|
||||
|
||||
end;
|
||||
|
||||
procedure TTestMarkupIfDef.CheckOpenCloseCount(AName: String; ALine: Integer; AExpOpenCnt,
|
||||
AExpCloseCnt: Integer);
|
||||
var
|
||||
@ -2169,7 +2200,6 @@ begin
|
||||
CheckNodesXY('Insert IFDEF into empty text', 3, [1,11], 0);
|
||||
{%endregion Insert IFDEF into empty text }
|
||||
|
||||
|
||||
{%region }
|
||||
n := '';
|
||||
ReCreateEditForTreeTest(TestText8);
|
||||
@ -2209,6 +2239,56 @@ FTestTree.DebugPrint(true);DebugLn('-----');
|
||||
|
||||
|
||||
|
||||
{%region }
|
||||
|
||||
|
||||
n := '';
|
||||
ReCreateEditForTreeTest(TestText11);
|
||||
FTestTree.ValidateRange( 1, 16, FOpenings);
|
||||
|
||||
FTestTree.SetNodeState( 2, 3, idnEnabled);
|
||||
FTestTree.SetNodeState( 4, 3, idnDisabled);
|
||||
FTestTree.SetNodeState( 6, 3, idnInvalid);
|
||||
FTestTree.SetNodeState( 8, 3, idnInvalid);
|
||||
|
||||
FTestTree.ValidateRange( 1, 16, FOpenings);
|
||||
//FTestTree.DebugPrint(true);DebugLn('-----');
|
||||
|
||||
//SynEdit.TextBetweenPoints[point( 7,3),point( 1,4)] := ''; // JOIN LINES
|
||||
SynEdit.TestTypeText(1, 4, #8, true);
|
||||
|
||||
|
||||
FTestTree.ValidateRange( 1, 16, FOpenings);
|
||||
FTestTree.SetNodeState( 2, 3, idnEnabled);
|
||||
//FTestTree.SetNodeState( 4, 3, idnDisabled);
|
||||
FTestTree.SetNodeState( 5, 3, idnInvalid);
|
||||
FTestTree.SetNodeState( 7, 3, idnInvalid);
|
||||
FTestTree.ValidateRange( 1, 16, FOpenings);
|
||||
|
||||
SynEdit.Undo; // RESTORE LINEBREAK
|
||||
SynEdit.SimulatePaintText;
|
||||
DebugLn('----- undone');FTestTree.DebugPrint(true);DebugLn('-----');
|
||||
|
||||
FTestTree.ValidateRange( 1, 16, FOpenings);
|
||||
DebugLn('----- valid');FTestTree.DebugPrint(true);DebugLn('-----');
|
||||
FTestTree.SetNodeState( 2, 3, idnEnabled);
|
||||
FTestTree.DebugPrint(true);DebugLn('-----');
|
||||
FTestTree.SetNodeState( 4, 3, idnDisabled);
|
||||
DebugLn('----- disabled');FTestTree.DebugPrint(true);DebugLn('-----');
|
||||
FTestTree.SetNodeState( 6, 3, idnInvalid);
|
||||
FTestTree.SetNodeState( 8, 3, idnInvalid);
|
||||
FTestTree.ValidateRange( 1, 16, FOpenings);
|
||||
|
||||
//FTestTree.DebugPrint(true);DebugLn('-----');
|
||||
SynEdit.TextBetweenPoints[point( 1,4),point( 1,5)] := '';
|
||||
FTestTree.ValidateRange( 1, 16, FOpenings);
|
||||
|
||||
|
||||
|
||||
{%endregion }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
FTestTree.DiscardOpeningList(FOpenings);
|
||||
|
Loading…
Reference in New Issue
Block a user