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

Commit 60a2d62

Browse filesBrowse files
committed
fixed logic
1 parent 39f0b69 commit 60a2d62
Copy full SHA for 60a2d62

File tree

4 files changed

+10
-22
lines changed
Filter options

4 files changed

+10
-22
lines changed

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
3636
use Symfony\Component\Console\Exception\CommandNotFoundException;
3737
use Symfony\Component\Console\Exception\LogicException;
38-
use Symfony\Component\Console\Terminal;
3938
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
4039

4140
/**

‎src/Symfony/Component/Console/Helper/ProgressBar.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/ProgressBar.php
+10-19Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,7 @@ public function display()
403403
$this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
404404
}
405405

406-
$line = $this->buildLine();
407-
$line = $this->adjustLineWidthToTerminalWidth($line);
408-
$this->overwrite($line);
406+
$this->overwrite($this->buildLine());
409407
}
410408

411409
/**
@@ -591,7 +589,8 @@ private static function initFormats()
591589
*/
592590
private function buildLine()
593591
{
594-
return preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) {
592+
$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
593+
$callback = function ($matches) {
595594
if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
596595
$text = call_user_func($formatter, $this, $this->output);
597596
} elseif (isset($this->messages[$matches[1]])) {
@@ -605,25 +604,17 @@ private function buildLine()
605604
}
606605

607606
return $text;
608-
}, $this->format);
609-
}
607+
};
608+
$line = preg_replace_callback($regex, $callback, $this->format);
610609

611-
/**
612-
* @param string $line
613-
*
614-
* @return bool
615-
*/
616-
private function adjustLineWidthToTerminalWidth($line)
617-
{
618610
$lineLength = Helper::strlenWithoutDecoration($this->output->getFormatter(), $line);
619611
$terminalWidth = $this->terminal->getWidth();
620-
if ($lineLength > $terminalWidth) {
621-
$newBarWidth = $this->barWidth - $lineLength + $terminalWidth;
622-
$this->setBarWidth($newBarWidth);
623-
624-
return $this->buildLine();
612+
if ($lineLength <= $terminalWidth) {
613+
return $line;
625614
}
626615

627-
return $line;
616+
$this->setBarWidth($this->barWidth - $lineLength + $terminalWidth);
617+
618+
return preg_replace_callback($regex, $callback, $this->format);
628619
}
629620
}

‎src/Symfony/Component/Console/Style/SymfonyStyle.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Style/SymfonyStyle.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Console\Style;
1313

14-
use Symfony\Component\Console\Application;
1514
use Symfony\Component\Console\Exception\RuntimeException;
1615
use Symfony\Component\Console\Formatter\OutputFormatter;
1716
use Symfony\Component\Console\Helper\Helper;

‎src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Console\Helper\ProgressBar;
1515
use Symfony\Component\Console\Helper\Helper;
1616
use Symfony\Component\Console\Output\StreamOutput;
17-
use Symfony\Component\Console\Terminal;
1817

1918
/**
2019
* @group time-sensitive

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.