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] progress bar fix #19012

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 5 commits into from
Jun 17, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed logic
  • Loading branch information
fabpot committed Jun 17, 2016
commit bf7a5c58a99c46b8493c23d276692b7d86a57ef1
1 change: 0 additions & 1 deletion 1 src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
use Symfony\Component\Console\Exception\CommandNotFoundException;
use Symfony\Component\Console\Exception\LogicException;
use Symfony\Component\Console\Terminal;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

/**
Expand Down
29 changes: 10 additions & 19 deletions 29 src/Symfony/Component/Console/Helper/ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,7 @@ public function display()
$this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
}

$line = $this->buildLine();
$line = $this->adjustLineWidthToTerminalWidth($line);
$this->overwrite($line);
$this->overwrite($this->buildLine());
}

/**
Expand Down Expand Up @@ -601,7 +599,8 @@ private static function initFormats()
*/
private function buildLine()
{
return preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) {
$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
$callback = function ($matches) {
if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
$text = call_user_func($formatter, $this, $this->output);
} elseif (isset($this->messages[$matches[1]])) {
Expand All @@ -615,25 +614,17 @@ private function buildLine()
}

return $text;
}, $this->format);
}
};
$line = preg_replace_callback($regex, $callback, $this->format);

/**
* @param string $line
*
* @return bool
*/
private function adjustLineWidthToTerminalWidth($line)
{
$lineLength = Helper::strlenWithoutDecoration($this->output->getFormatter(), $line);
$terminalWidth = $this->terminal->getWidth();
if ($lineLength > $terminalWidth) {
$newBarWidth = $this->barWidth - $lineLength + $terminalWidth;
$this->setBarWidth($newBarWidth);

return $this->buildLine();
if ($lineLength <= $terminalWidth) {
return $line;
}

return $line;
$this->setBarWidth($this->barWidth - $lineLength + $terminalWidth);

return preg_replace_callback($regex, $callback, $this->format);
}
}
1 change: 0 additions & 1 deletion 1 src/Symfony/Component/Console/Style/SymfonyStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Component\Console\Style;

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Helper\Helper;
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Console/Terminal.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getWidth()
/**
* Sets the terminal width.
*
* @param int
* @param int $width
*/
public function setWidth($width)
{
Expand All @@ -57,7 +57,7 @@ public function getHeight()
/**
* Sets the terminal height.
*
* @param int
* @param int $height
*/
public function setHeight($height)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Terminal;

/**
* @group time-sensitive
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.