TurboPack / SynEdit

SynEdit is a syntax highlighting edit control, not based on the Windows common controls.
224 stars 75 forks source link

fixed: Exception "TList<System.Integer> is empty" #262

Open ma3as opened 1 month ago

ma3as commented 1 month ago

With create a new project there seems no problem.

When I open my project with the SynEdit component, the IDE shows me an error, before the Designer is ready. Also when run the project, while create the form where the SynEdit is placed on (sorry is german):

Exception: EArgumentOutOfRangeException mit der Meldung 'Listenindex außerhalb des gültigen Bereichs (0). TList ist leer' aufgetreten.

It happens in the unit SynEditWordWrap, here:

function TSynWordWrapPlugin.RowCount: integer;
begin
  if fLineCount > 0 then
    Result := fLineOffsets[fLineCount - 1]   // here it crashing
  else
    Result := 0;
  Assert(fRowLengths.Count = Result);
end;

Compiled with Delphi 10.1 Berlin there was no problem - now I use 12.2 Athens and it shows the error.

How to fix?

ma3as commented 1 month ago

Hi, I fixed that issue for me: if (fLineOffsets.Count > 0) // and (fLineCount > 0)

Now it works without Exception.