Synedit: Fixed insert space in new empty text, would cause exception

git-svn-id: trunk@19008 -
This commit is contained in:
martin 2009-03-16 20:26:21 +00:00
parent 8e7fc1ea58
commit 51d4db2ebc

View File

@ -742,8 +742,6 @@ end;
procedure TSynEditStringList.PutRange(Index: integer; ARange: TSynEditRange); procedure TSynEditStringList.PutRange(Index: integer; ARange: TSynEditRange);
begin begin
if (Index < 0) or (Index >= Count) then
ListIndexOutOfBounds(Index);
{$IFDEF SYN_LAZARUS} {$IFDEF SYN_LAZARUS}
// do not call BeginUpdate/EndUpdate. It would call the too generic OnChange // do not call BeginUpdate/EndUpdate. It would call the too generic OnChange
// events // events
@ -759,18 +757,22 @@ function TSynEditStringList.GetAttribute(const Owner: TClass; const Index: Integ
var var
i: Integer; i: Integer;
begin begin
if (Index = 0) and (Count = 0) then
exit(nil);
if (Index < 0) or (Index >= Count) then if (Index < 0) or (Index >= Count) then
ListIndexOutOfBounds(Index); ListIndexOutOfBounds(Index);
i := ClassIndexForAttribute(Owner); i := ClassIndexForAttribute(Owner);
if i < 0 then if i < 0 then
raise ESynEditStringList.CreateFmt('Unknown Attribute', []); raise ESynEditStringList.CreateFmt('Unknown Attribute', []);
Result := FList.Attribute[Index, FAttributeList[i].Pos, FAttributeList[i].Size]; Result := FList.Attribute[Index, FAttributeList[i].Pos, FAttributeList[i].Size]
end; end;
procedure TSynEditStringList.SetAttribute(const Owner: TClass; const Index: Integer; const AValue: Pointer); procedure TSynEditStringList.SetAttribute(const Owner: TClass; const Index: Integer; const AValue: Pointer);
var var
i: Integer; i: Integer;
begin begin
if (Index = 0) and (Count = 0) then
Add('');
if (Index < 0) or (Index >= Count) then if (Index < 0) or (Index >= Count) then
ListIndexOutOfBounds(Index); ListIndexOutOfBounds(Index);
i := ClassIndexForAttribute(Owner); i := ClassIndexForAttribute(Owner);