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

Appearance settings

[Console] SymfonyStyle : fix blocks output is broken on windows cmd #14740

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

Merged
merged 1 commit into from
Jun 8, 2015
Merged

[Console] SymfonyStyle : fix blocks output is broken on windows cmd #14740

merged 1 commit into from
Jun 8, 2015

Conversation

ogizanagi
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

Using SymfonyStyle::block method, output is broken on windows cmd:
screenshot 2015-05-23 a 18 00 18 - copie

Windows cmd seems to wrap lines as soon as the terminal width is reached, whether there are following characters or not.

I've encountered this behavior with multiple command prompts available on Windows, like Console2, ConEmu, Cmdr, ... But as most of them are simple cmd wrappers, the output is identic. The only good fellow in there is Cygwin which provides an Unix-like env and command-line interface.

This PR solves this issue by assuming that the lineLength (not the terminal width), used to wrap lines internally within the SymfonyStyle::block method, should be the terminal width - 1.

@@ -44,7 +44,7 @@ class SymfonyStyle extends OutputStyle
public function __construct(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->lineLength = min($this->getTerminalWidth(), self::MAX_LINE_LENGTH);
$this->lineLength = min($this->getTerminalWidth() - (int) (DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That probably deserves a small comment to indicate why there is such a "hack" here.

@fabpot
Copy link
Member

fabpot commented Jun 8, 2015

👍

$this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter());
// Windows cmd wraps lines as soon as the terminal width is reached, whether there are following chars or not.
// https://github.com/symfony/symfony/pull/14740
$this->lineLength = min($this->getTerminalWidth() - (int) (DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabpot : Is it sufficient ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the github reference, there is no need for that as the merge commit already contains everything we need to know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@fabpot
Copy link
Member

fabpot commented Jun 8, 2015

Thank you @ogizanagi.

@fabpot fabpot merged commit ea3d768 into symfony:2.7 Jun 8, 2015
fabpot added a commit that referenced this pull request Jun 8, 2015
…ndows cmd (ogizanagi)

This PR was merged into the 2.7 branch.

Discussion
----------

[Console] SymfonyStyle : fix blocks output is broken on windows cmd

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Using `SymfonyStyle::block` method, output is broken on windows cmd:
![screenshot 2015-05-23 a 18 00 18 - copie](https://cloud.githubusercontent.com/assets/2211145/7788763/43135ea0-0249-11e5-8a82-7f788384bc03.PNG)

Windows cmd seems to wrap lines as soon as the terminal width is reached, whether there are following characters or not.

I've encountered this behavior with multiple command prompts available on Windows, like Console2, ConEmu, Cmdr, ... But as most of them are simple cmd wrappers, the output is identic. The only good fellow in there is Cygwin which provides an Unix-like env and command-line interface.

This PR solves this issue by assuming that the lineLength (not the terminal width), used to wrap lines internally within the `SymfonyStyle::block` method, should be the terminal width - 1.

Commits
-------

ea3d768 [Console] SymfonyStyle : Fix blocks output is broken on windows cmd
@ogizanagi ogizanagi deleted the sfstyle/fix_win_blocks_padding branch June 8, 2015 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.