Skip to content

[Console] Question helper is behaving differently when inside a Section #47411

Closed
@bigfoot90

Description

@bigfoot90

Symfony version(s) affected

6.1.4

Description

The question helper is going onto a new line when used inside a Section, therefore section cannot rewrite correctly

How to reproduce

Question helper only

Code
      $io = new SymfonyStyle($input, $output);

      $countdown = 3;
      while ($countdown > 0) {
          $io->write('Lorem ipsum ' . $countdown);
          $random = $io->ask('Press random key');
          $countdown--;
      }

Section helper only

Code
      $section = $output->section();

      $countdown = 3;
      while ($countdown > 0) {
          $section->clear();
          $section->write('Lorem ipsum ' . $countdown);
          $countdown--;
          sleep(1);
      }

Both combined

Code
      $section = $output->section();
      $io = new SymfonyStyle($input, $section);

      $countdown = 3;
      while ($countdown > 0) {
          $section->clear();
          $section->write('Lorem ipsum ' . $countdown);

          $random = $io->ask('Press random key');
          $countdown--;
      }

Expected

Final output should be

Lorem ipsum 1

 Press random key:
 > something

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