SynEdit: fix superfluous invalidate while scrolling

This commit is contained in:
Martin 2024-09-01 14:19:35 +02:00
parent 7fddb710b3
commit cf462fa18d
2 changed files with 20 additions and 1 deletions

View File

@ -48,6 +48,7 @@ type
TSynMarkupHighAllMatchList = class(TSynEditStorageMem) TSynMarkupHighAllMatchList = class(TSynEditStorageMem)
private private
FChangeStamp: int64;
function GetEndPoint(const Index : Integer) : TPoint; function GetEndPoint(const Index : Integer) : TPoint;
function GetPoint(const Index : Integer) : TPoint; function GetPoint(const Index : Integer) : TPoint;
function GetPointCount : Integer; function GetPointCount : Integer;
@ -85,6 +86,7 @@ type
property EndPoint [const Index : Integer] : TPoint read GetEndPoint write SetEndPoint; property EndPoint [const Index : Integer] : TPoint read GetEndPoint write SetEndPoint;
property PointCount : Integer read GetPointCount; property PointCount : Integer read GetPointCount;
property Point [const Index : Integer] : TPoint read GetPoint; property Point [const Index : Integer] : TPoint read GetPoint;
property ChangeStamp: int64 read FChangeStamp;
end; end;
{ TSynMarkupHighAllMultiMatchList - Allow matches with different markup / no overlap } { TSynMarkupHighAllMultiMatchList - Allow matches with different markup / no overlap }
@ -1833,6 +1835,7 @@ begin
exit; exit;
if AIndex + ACount > Count then if AIndex + ACount > Count then
ACount := Count - AIndex; ACount := Count - AIndex;
{$PUSH}{$R-}{$Q-}FChangeStamp := FChangeStamp+1;{$POP}
DeleteRows(AIndex, ACount); DeleteRows(AIndex, ACount);
end; end;
@ -1840,11 +1843,13 @@ procedure TSynMarkupHighAllMatchList.Insert(AIndex: Integer; ACount: Integer);
begin begin
if AIndex > Count then if AIndex > Count then
exit; exit;
{$PUSH}{$R-}{$Q-}FChangeStamp := FChangeStamp+1;{$POP}
InsertRows(AIndex, ACount); InsertRows(AIndex, ACount);
end; end;
procedure TSynMarkupHighAllMatchList.Insert(AIndex: Integer; AStartPoint, AEndPoint: TPoint); procedure TSynMarkupHighAllMatchList.Insert(AIndex: Integer; AStartPoint, AEndPoint: TPoint);
begin begin
{$PUSH}{$R-}{$Q-}FChangeStamp := FChangeStamp+1;{$POP}
Insert(AIndex); Insert(AIndex);
PSynMarkupHighAllMatch(ItemPointer[AIndex])^.StartPoint := AStartPoint; PSynMarkupHighAllMatch(ItemPointer[AIndex])^.StartPoint := AStartPoint;
PSynMarkupHighAllMatch(ItemPointer[AIndex])^.EndPoint := AEndPoint; PSynMarkupHighAllMatch(ItemPointer[AIndex])^.EndPoint := AEndPoint;
@ -1853,6 +1858,7 @@ end;
procedure TSynMarkupHighAllMatchList.SetCount(const AValue : Integer); procedure TSynMarkupHighAllMatchList.SetCount(const AValue : Integer);
begin begin
if Count=AValue then exit; if Count=AValue then exit;
{$PUSH}{$R-}{$Q-}FChangeStamp := FChangeStamp+1;{$POP}
if (Capacity <= AValue) then begin if (Capacity <= AValue) then begin
Capacity := Max(Capacity, AValue) * 2; Capacity := Max(Capacity, AValue) * 2;
inherited SetCount(AValue); inherited SetCount(AValue);
@ -1885,6 +1891,7 @@ begin
if Index = Count if Index = Count
then Count := Count + 1; // AutoIncrease then Count := Count + 1; // AutoIncrease
PSynMarkupHighAllMatch(ItemPointer[Index])^.StartPoint := AValue; PSynMarkupHighAllMatch(ItemPointer[Index])^.StartPoint := AValue;
{$PUSH}{$R-}{$Q-}FChangeStamp := FChangeStamp+1;{$POP}
end; end;
function TSynMarkupHighAllMatchList.GetInintialForItemSize: Integer; function TSynMarkupHighAllMatchList.GetInintialForItemSize: Integer;
@ -1902,6 +1909,7 @@ begin
if Index = Count if Index = Count
then Count := Count + 1; // AutoIncrease then Count := Count + 1; // AutoIncrease
PSynMarkupHighAllMatch(ItemPointer[Index])^.EndPoint := AValue; PSynMarkupHighAllMatch(ItemPointer[Index])^.EndPoint := AValue;
{$PUSH}{$R-}{$Q-}FChangeStamp := FChangeStamp+1;{$POP}
end; end;
function TSynMarkupHighAllMatchList.GetMatch(const Index: Integer): TSynMarkupHighAllMatch; function TSynMarkupHighAllMatchList.GetMatch(const Index: Integer): TSynMarkupHighAllMatch;
@ -1915,6 +1923,7 @@ begin
if Index = Count if Index = Count
then Count := Count + 1; // AutoIncrease then Count := Count + 1; // AutoIncrease
PSynMarkupHighAllMatch(ItemPointer[Index])^ := AValue; PSynMarkupHighAllMatch(ItemPointer[Index])^ := AValue;
{$PUSH}{$R-}{$Q-}FChangeStamp := FChangeStamp+1;{$POP}
end; end;
{ TSynMarkupHighAllMultiMatchList } { TSynMarkupHighAllMultiMatchList }
@ -2147,6 +2156,7 @@ var
var var
EndOffsLine: Integer; EndOffsLine: Integer;
Idx: Integer; Idx: Integer;
ch: Int64;
begin begin
// Check, if there is exactly one match in the visible lines // Check, if there is exactly one match in the visible lines
if (not HideSingleMatch) or (Matches.Count <> 1) or if (not HideSingleMatch) or (Matches.Count <> 1) or
@ -2161,10 +2171,12 @@ var
if ComparePoints(FSearchedEnd, FMatches.EndPoint[0]) < 0 then if ComparePoints(FSearchedEnd, FMatches.EndPoint[0]) < 0 then
FSearchedEnd := FMatches.EndPoint[0]; FSearchedEnd := FMatches.EndPoint[0];
Idx := 1; Idx := 1;
ch := FMatches.ChangeStamp;
FSearchedEnd := FindMatches(FSearchedEnd, FSearchedEnd := FindMatches(FSearchedEnd,
Point(Length(Lines[EndOffsLine - 1])+1, EndOffsLine), Point(Length(Lines[EndOffsLine - 1])+1, EndOffsLine),
Idx, LastScreenLine); Idx, LastScreenLine);
SendLineInvalidation; if ch <> FMatches.ChangeStamp then
SendLineInvalidation;
if Idx > 1 then if Idx > 1 then
exit; exit;
end; end;

View File

@ -671,6 +671,13 @@ var
rcInval: TRect; rcInval: TRect;
begin begin
if not Enabled then exit; if not Enabled then exit;
if FGlyphAtLine = -1 then
FGlyphAtLine := TCustomSynEdit(SynEdit).CaretY;
if ( (FGlyphAtLine = -1) and (FGlyphLastLine = TCustomSynEdit(SynEdit).CaretY) ) or
( (FGlyphAtLine <>-1) and (FGlyphLastLine = FGlyphAtLine) )
then
exit;
if FGlyphLastLine <> -2 then begin if FGlyphLastLine <> -2 then begin
if SynEdit.HandleAllocated then begin if SynEdit.HandleAllocated then begin
rcInval := GetGutterGlyphRect(FGlyphLastLine); rcInval := GetGutterGlyphRect(FGlyphLastLine);