node icon indicating copy to clipboard operation
node copied to clipboard

[readline] Multiline question eats the output from the completer

Open 3amPKX4WrH opened this issue 1 month ago • 0 comments

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

3amPKX4WrH avatar Dec 04 '25 21:12 3amPKX4WrH