Skip to content

Commit 413a6ef

Browse files
author
Kapil Borle
committed
Handle TextLines.Insert when index equals number of items
1 parent bc483e7 commit 413a6ef

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

Engine/TextLines.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,7 @@ public string this[int index]
8686
/// <param name="item">A non null object of type String.</param>
8787
public void Add(string item)
8888
{
89-
if (item == null)
90-
{
91-
throw new ArgumentNullException(nameof(item));
92-
}
93-
94-
Insert(Count - 1, item);
89+
Insert(Count, item);
9590
}
9691

9792
/// <summary>
@@ -165,6 +160,10 @@ public void Insert(int index, string item)
165160
{
166161
itemInserted = lines.AddFirst(item);
167162
}
163+
else if (Count == index)
164+
{
165+
itemInserted = lines.AddLast(item);
166+
}
168167
else
169168
{
170169
ValidateIndex(index);

0 commit comments

Comments
 (0)