fix(core): Fixes wrap not slicing properly (#362)
- [X] Fixes wrap not slicing properly Bumps release version
This commit is contained in:
parent
10a6e17640
commit
9c9591b098
2 changed files with 7 additions and 7 deletions
|
|
@ -43,6 +43,8 @@ namespace Server.Tests
|
|||
|
||||
[Theory]
|
||||
[InlineData("this is a sentence that will probably wrap around a few times because it is long", 10, 6)]
|
||||
[InlineData("An Unnamed House", 10, 6)]
|
||||
[InlineData("Batville", 10, 6)]
|
||||
public void TestWrap(string sentence, int perLine, int maxLines)
|
||||
{
|
||||
var expected = OldWrap(sentence, perLine, maxLines);
|
||||
|
|
|
|||
|
|
@ -188,17 +188,15 @@ namespace Server
|
|||
|
||||
var newLineLength = lineLength + spaceIndex;
|
||||
|
||||
if (newLineLength == perLine || newLineLength == span.Length - 1)
|
||||
if (newLineLength == perLine || newLineLength == span.Length)
|
||||
{
|
||||
// Could be the end of the string
|
||||
var length = span[newLineLength] == ' ' ? newLineLength - 1 : newLineLength;
|
||||
list.Add(span.Slice(0, length).ToString());
|
||||
if (list.Count == maxLines)
|
||||
list.Add(span.Slice(0, newLineLength).ToString());
|
||||
if (list.Count == maxLines || newLineLength == span.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
span = span.Slice(newLineLength);
|
||||
span = span.Slice(newLineLength + 1);
|
||||
lineLength = 0;
|
||||
}
|
||||
else if (newLineLength < perLine)
|
||||
|
|
@ -235,7 +233,7 @@ namespace Server
|
|||
index += perLine;
|
||||
}
|
||||
|
||||
span = span.Slice(lineLength);
|
||||
span = span.Slice(newLineLength - lineLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue