Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[String] Fix ellipsis of truncate when not using cut option#37054
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| ['fo','foobar',2,'...'], | ||
| ['...','foobar',3,'...'], | ||
| ['fo...','foobar',5,'...'], | ||
| ['foobar...','foobar foo',6,'...',false], |
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.
Sort-of unrelated, but what happens with['???', 'foobar', 5, '...'],
ie. if($length + $ellipsisLength) > $stringLength?
It should return the full string then, possibly?
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 what you mean, please provide a test case if you want.
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 was not sure whether the length provided to the method is including or excluding the ellipsis. But apparently it is, so the case I talked about can't happen here.
So nvm then 👍
4d0133c toa2ee6c6Compare
nicolas-grekas left a 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 updated the implementation to make more local, good catch overall.
| ['fo','foobar',2,'...'], | ||
| ['...','foobar',3,'...'], | ||
| ['fo...','foobar',5,'...'], | ||
| ['foobar...','foobar foo',6,'...',false], |
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 what you mean, please provide a test case if you want.
nicolas-grekas commentedJun 11, 2020
Thank you@duboiss. |
Since 5.1, we can use a cut option on truncate.
But with this option, we don't have the expected behavior when the entire chain is returned.
Currently:
u('Lorem Ipsum')->truncate(8, '…', false); // 'Lorem Ipsum...'Instead of:
u('Lorem Ipsum')->truncate(8, '…', false); // 'Lorem Ipsum'Thanks to@jmsche for his help.