Skip to content

Console component: Incompletely cleared section when a question is asked #28615

@stefanszymanski

Description

@stefanszymanski

Symfony version(s) affected: 4.1.4

Description
When using \Symfony\Component\Console\OutputConsoleSectionOutput::clear() after displaying a Question (regardless whether with or without \Symfony\Component\Console\Style\SymfonyStyle) the last previous line of the section isn't cleared.

How to reproduce

class SomeCommand extends \Symfony\Component\Console\Command\Command
{
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $section = $output->section();

        $section->writeln('aaa');
        $section->writeln('aaa');
        // Output:
        // aaa
        // aaa

        $question = new Question('???');
        $questionHelper = new QuestionHelper();
        $questionHelper->ask($input, $section, $question);
        // Output:
        // aaa
        // aaa
        // ???

        $section->clear();
        $section->writeln('bbb');
        $section->writeln('bbb');
        // Output:
        // aaa
        // bbb
        // bbb
    }
}

Possible Solution
I didn't found any.

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