SynEdit: Optimization for processing multi-carets (updating huge amounts during scrolling). Part of issue: #35854

git-svn-id: trunk@61650 -
This commit is contained in:
martin 2019-07-31 21:13:52 +00:00
parent c162d92785
commit a2c415d5e2

View File

@ -1670,7 +1670,7 @@ end;
procedure TSynPluginMultiCaretBase.UpdateCaretsPos;
var
i, x, y, o, w: Integer;
y1, y2: Integer;
y1, y2, TopLine, BottomLine: Integer;
vis: Boolean;
begin
if plfDeferUpdateCaretsPos in FPaintLockFlags then exit;
@ -1678,6 +1678,9 @@ begin
include(FPaintLockFlags, plfUpdateCaretsPos);
exit;
end;
if CaretsCount = 0 then
exit;
if (eoNoCaret in Editor.Options) then begin
for i := 0 to CaretsCount - 1 do
Carets.Visual[i] := nil;
@ -1687,11 +1690,18 @@ begin
vis := (eoPersistentCaret in Editor.Options) or Editor.Focused;
w := Editor.LinesInWindow + 1;
TopLine := Editor.TopLine;
BottomLine := Editor.ScreenRowToRow(w);
for i := 0 to CaretsCount - 1 do begin
if cfNoneVisual in Carets.Flags[i] then continue;
x := Carets.CaretX[i];
y := Carets.CaretY[i];
if (y < TopLine) or (y > BottomLine) then begin
Carets.Visual[i] := nil;
continue;
end;
x := Carets.CaretX[i];
o := Carets.CaretOffs[i];
y1 := Editor.RowToScreenRow(y);
if (y1 < 0) or (y1 > w) then begin