Skip to content

[Console] Format unset codes break with scrollbar #27832

@ro0NL

Description

@ro0NL

Symfony version(s) affected: 4.1, probably lower as well

Description

When working on #22225, i noticed something goes wrong with the CLI unset codes as soon a formatted text spans multiple lines, and the output exceeds the window ($LINES), thus when the scrollbar becomes active.

See #22225 (comment)

How to reproduce

My console window ($LINES x $COLUMNS) is set to 12 x 72

I quickly patched the AboutCommand as follow:

diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
index b6860a2..973c1e1 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
@@ -56,6 +56,9 @@ EOT
      */
     protected function execute(InputInterface $input, OutputInterface $output)
     {
+        $output->writeln(str_repeat("pre <error>foo bar baz</error> post", 15));
+        return 0;
+
         $io = new SymfonyStyle($input, $output);

Now running it during 1 session (my scrollbar is invisible here btw 😅)

1st 👍

image

2nd 👍

image

3rd 👎

image

Possible Solution
Not sure, I hope someone can explain what's happening technically.

Additional context

return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy