Skip to content

[readline] Multiline question eats the output from the completer #60952

@3amPKX4WrH

Description

@3amPKX4WrH

Version

v22.11.0

Platform

Microsoft Windows NT 10.0.26100.0 x64

Subsystem

No response

What steps will reproduce the bug?

import { CompleterResult, createInterface } from 'readline';

const rl = createInterface({
    input: process.stdin,
    output: process.stdout,
    completer: (line: string): CompleterResult => {
        return [
            [
                'foobar',
                'foobaz'
            ],
            line
        ]
    }
});

rl.question(`multiline
prompt
eats
output
> `, () => { })

With running the above code, type "foo" in the console and press tab, the completer successfully fill it to "fooba":

multiline
prompt
eats
output
> fooba

If try to press again to list all possible values, the multiline prompt will erase the output from the completer:

multiline
prompt
eats
multiline
prompt
eats
output
> fooba

How often does it reproduce? Is there a required condition?

As long as the prompt has more than 1 line, this issue occurs. Though you can still see the output if you prompt is 2 lines as the last line of the output from completer is an empty line.

What is the expected behavior? Why is that the expected behavior?

multiline
prompt
eats
output
> fooba
foobar  foobaz

multiline
prompt
eats
output
> fooba

What do you see instead?

multiline
prompt
eats
multiline
prompt
eats
output
> fooba

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions