I upgraded from the older version to a new one and it seems to me that the new version has a bug in TSynEditStringList.DeleteLines procedure. I diffed two SynEditTextBuffer.pas files and see changes in this function. Particularly two "- 1" were added to the newer version and that doesn't make sense to me. Can you review the code of this procedure?
Affected lines in the new version:
...
LinesAfter := fCount - (Index + NumLines - 1);
...
NumLines := fCount - Index - 1;
...
For you convenience I am sending the code of this function from the older version, which I think is correct one. The oldest version in the source forge codebase already has these "- 1", that's why I am sending the old code.
From SynEditTextBuffer.pas,v 1.63.2.12 2006/05/22 10:51:21 maelh:
...
procedure TSynEditStringList.DeleteLines(Index, NumLines: Integer);
var
LinesAfter: integer;
{$IFDEF OWN_WIDESTRING_MEMMGR}
I: Integer;
{$ENDIF OWN_WIDESTRING_MEMMGR}
begin
if NumLines > 0 then begin
if (Index < 0) or (Index > fCount) then
ListIndexOutOfBounds(Index);
LinesAfter := fCount - (Index + NumLines);
if LinesAfter < 0 then
NumLines := fCount - Index;
{$IFDEF OWN_WIDESTRING_MEMMGR}
for I := Index to Index + NumLines - 1 do
with FList[I] do
if TDynWideCharArray(FString) <> nil then
TDynWideCharArray(FString) := nil;
{$ELSE}
Dec(fCount, NumLines);
Finalize(fList^[Index], NumLines);
{$ENDIF OWN_WIDESTRING_MEMMGR}
if LinesAfter > 0 then begin
BeginUpdate;
try
System.Move(fList^[Index + NumLines], fList^[Index],
LinesAfter * SynEditStringRecSize);
finally
EndUpdate;
end;
end;
if Assigned(fOnDeleted) then
fOnDeleted( Self, Index, NumLines );
end;
end;
...