Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
nicolas-grekas merged 1 commit intosymfony:5.1fromduboiss:fix_string_truncate
Jun 11, 2020

Conversation

@duboiss
Copy link
Contributor

QA
Branch?5.1
Bug fix?yes
New feature?no
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

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.

['fo','foobar',2,'...'],
['...','foobar',3,'...'],
['fo...','foobar',5,'...'],
['foobar...','foobar foo',6,'...',false],
Copy link
Contributor

@apfelboxapfelboxJun 2, 2020
edited
Loading

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?

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.

Copy link
Contributor

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 👍

@nicolas-grekasnicolas-grekas added this to the5.1 milestoneJun 4, 2020
Copy link
Member

@nicolas-grekasnicolas-grekas left a 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],

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
Copy link
Member

Thank you@duboiss.

@nicolas-grekasnicolas-grekas merged commit69c37c0 intosymfony:5.1Jun 11, 2020
@fabpotfabpot mentioned this pull requestJun 12, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+2 more reviewers

@apfelboxapfelboxapfelbox left review comments

@jmschejmschejmsche approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

5.1

Development

Successfully merging this pull request may close these issues.

5 participants

@duboiss@nicolas-grekas@apfelbox@jmsche@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp