-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ansi): cut/truncate/truncateleft improperly handling new lines #367
Conversation
I'm not sure this is the best way to handle this, but, without this patch, truncates would still use new lines from outside its cut target. This fixes it.
This is related to #351 |
Could you add the tests from #351 here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TruncateLeft still ignores newlines even if they're within the range
seems to be working fine to me, even added another test for it. PS: the problem was that it wasn't ignoring out of the cut new lines - so it was including all of them. |
@@ -142,6 +143,14 @@ func truncate(m Method, s string, length int, tail string) string { | |||
// collects printable ASCII | |||
curWidth++ | |||
fallthrough | |||
case parser.ExecuteAction: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so in case of a new line, it will be ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind saw your comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I'm not sure this is the best way to handle this, but, without this
patch, truncates would still use new lines from outside its cut target.
This fixes it.
closes #351