Fixed an issue with a character being dropped in GetStringLines()
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded

This commit is contained in:
Brychan Dempsey 2021-03-24 15:35:56 +13:00
parent f3bf997652
commit 442a967cd9

View File

@ -896,11 +896,12 @@ namespace Assignment_1
static List<string> GetStringLines(string source, int maxWidth)
{
List<string> lines = new();
for (int i = 0; i < source.Length; i++)
int j = 0;
while (j < source.Length)
{
int max = i + maxWidth <= source.Length ? i + maxWidth : source.Length;
lines.Add(source[i..max]);
i = max;
int max = j + maxWidth <= source.Length ? j + maxWidth : source.Length;
lines.Add(source[j..max]);
j = max;
}
return lines;
}