We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4ed988b commit bc483e7Copy full SHA for bc483e7
1 file changed
Engine/TextLines.cs
@@ -159,9 +159,19 @@ public int IndexOf(string item)
159
/// </summary>
160
public void Insert(int index, string item)
161
{
162
- ValidateIndex(index);
163
ThrowIfNull(item, nameof(item));
164
- SetLastAccessed(index, lines.AddBefore(GetNodeAt(index), item));
+ LinkedListNode<string> itemInserted;
+ if (Count == 0 && index == 0)
165
+ {
166
+ itemInserted = lines.AddFirst(item);
167
+ }
168
+ else
169
170
+ ValidateIndex(index);
171
+ itemInserted = lines.AddBefore(GetNodeAt(index), item);
172
173
+
174
+ SetLastAccessed(index, itemInserted);
175
Count++;
176
}
177
0 commit comments