SynEdit: Markup fold color... fix array len, patch from issue #31049

git-svn-id: trunk@53987 -
This commit is contained in:
martin 2017-01-24 01:29:29 +00:00
parent fad73bb819
commit b32479366d

View File

@ -82,11 +82,12 @@ type
FFirstCharacterColumnCache: Array of Byte; FFirstCharacterColumnCache: Array of Byte;
FEndLineCache: Array of Integer; FEndLineCache: Array of Integer;
FCacheCount, FCacheCount,
FCacheCapacity: Integer; FCacheCapacity,
FFoldColorInfosCount,
FFoldColorInfosCapacity: Integer;
FDefaultGroup: integer; FDefaultGroup: integer;
FFoldColorInfos: TMarkupFoldColorInfos; FFoldColorInfos: TMarkupFoldColorInfos;
FFoldColorInfosCount: Integer;
Colors : array of TColor; Colors : array of TColor;
FPreparedRow: integer; FPreparedRow: integer;
@ -95,6 +96,7 @@ type
procedure DoMarkupParentCloseFoldAtRow(aRow: Integer); procedure DoMarkupParentCloseFoldAtRow(aRow: Integer);
procedure SetDefaultGroup(AValue: integer); procedure SetDefaultGroup(AValue: integer);
procedure SetCacheCount(pNewCount: Integer); procedure SetCacheCount(pNewCount: Integer);
procedure SetFoldColorInfosCount(pNewCount: Integer);
procedure InitCache; procedure InitCache;
procedure ClearCache; procedure ClearCache;
property FirstCharacterColumn[index: Integer]: Byte read GetFirstCharacterColumn; property FirstCharacterColumn[index: Integer]: Byte read GetFirstCharacterColumn;
@ -150,6 +152,7 @@ begin
FDefaultGroup := 0; FDefaultGroup := 0;
FFoldColorInfosCount := 0; FFoldColorInfosCount := 0;
SetLength(FFoldColorInfos, 50); SetLength(FFoldColorInfos, 50);
FFoldColorInfosCapacity := 50;
FNestList := TLazSynEditNestedFoldsList.Create(Lines, FHighlighter); FNestList := TLazSynEditNestedFoldsList.Create(Lines, FHighlighter);
FNestList.ResetFilter; FNestList.ResetFilter;
@ -298,7 +301,7 @@ var
DebugLn('!!! TSynEditMarkupFoldColors.DoMarkupParentFoldAtRow: FEndLine-Array too small !!!'); DebugLn('!!! TSynEditMarkupFoldColors.DoMarkupParentFoldAtRow: FEndLine-Array too small !!!');
end; end;
end; end;
inc(FFoldColorInfosCount); SetFoldColorInfosCount(FFoldColorInfosCount + 1);
with FFoldColorInfos[FFoldColorInfosCount - 1] do begin with FFoldColorInfos[FFoldColorInfosCount - 1] do begin
SrcNode:= ANode; //needed by close node SrcNode:= ANode; //needed by close node
@ -403,7 +406,7 @@ var
FFoldColorInfos[j].Border := False FFoldColorInfos[j].Border := False
end; end;
inc(FFoldColorInfosCount); SetFoldColorInfosCount(FFoldColorInfosCount + 1);
with FFoldColorInfos[FFoldColorInfosCount - 1] do begin with FFoldColorInfos[FFoldColorInfosCount - 1] do begin
Border := False; Border := False;
SrcNode:= ANode; //needed by close node SrcNode:= ANode; //needed by close node
@ -604,6 +607,18 @@ begin
FCacheCount := pNewCount; FCacheCount := pNewCount;
end; end;
procedure TSynEditMarkupFoldColors.SetFoldColorInfosCount(pNewCount: Integer);
var
i: Integer;
begin
if pNewCount > FFoldColorInfosCapacity then begin
// expand array
FFoldColorInfosCapacity := pNewCount + 49;
SetLength(FFoldColorInfos, FFoldColorInfosCapacity);
end;
FFoldColorInfosCount := pNewCount;
end;
procedure TSynEditMarkupFoldColors.InitCache; procedure TSynEditMarkupFoldColors.InitCache;
begin begin
if Assigned(FNestList) then if Assigned(FNestList) then