Skip to content
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

[Console] fix emojis messing up the line width #40524

Merged
merged 1 commit into from
Mar 23, 2021

Conversation

MarionLeHerisson
Copy link
Contributor

@MarionLeHerisson MarionLeHerisson commented Mar 19, 2021

Q A
Branch? 5.2
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #37904
License MIT

Description

The emojis, because they take as much space as two characters, would cause the console to display too many spaces to complete a line, which made it uneven, as described in the issue.

The fix uses the width function instead of strlen. To answer @ogizanagi's comment, yes it does work with "composed" emojis.

Before :

image

After :

image

Other changes

Removed two unused lines of code, the value of $messageLineLength was never used.

Note

I'd like to add some tests, but I don't know how since I think this depends on console client width ?

Thanks for your reviews 🙏

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.x branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@MarionLeHerisson MarionLeHerisson changed the title [Command] fix emojis messing up the line width [WIP][Command] fix emojis messing up the line width Mar 19, 2021
@carsonbot carsonbot changed the title [WIP][Command] fix emojis messing up the line width [Console] [WIP][Command] fix emojis messing up the line width Mar 20, 2021
@chalasr
Copy link
Member

chalasr commented Mar 20, 2021

Do we really need a new method? Can't we update strlenWithoutDecoration() instead? (I may miss some potential issues due to the behavior change.)
The name of the new method does not make it obvious that it is all about strings.
So if we cannot just update strlenWithoutDecoration(), we should try to find a more meaningful name. Perhaps stringWidthWithoutDecoration() or similar?

@MarionLeHerisson
Copy link
Contributor Author

MarionLeHerisson commented Mar 22, 2021

Hello @chalasr, thanks for the feedback. Since the method is used in 13 other places in the code, I was afraid it would break something. But after trying it and running the tests, it seems it doesn't 👍

@MarionLeHerisson MarionLeHerisson changed the title [Console] [WIP][Command] fix emojis messing up the line width [Console] fix emojis messing up the line width Mar 22, 2021
add tests + removed irrelevant method
Copy link
Member

@nicolas-grekas nicolas-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 applied my own review comment and fixed a few more things found meanwhile)

@nicolas-grekas
Copy link
Member

Thank you @MarionLeHerisson.

@Nyholm
Copy link
Member

Nyholm commented Apr 3, 2021

I like this feature, however, it caused some regressions. I will revert this an add it as a new feature in 5.3 instead.

See #40697

Awilum added a commit to thermage/thermage that referenced this pull request Oct 18, 2021
symfony/symfony#40524

will be investigated and implemented in future Termage releases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Console with emoji mess up the formatting
5 participants