SBoudrias / Inquirer.js

A collection of common interactive command line user interfaces.
MIT License
19.64k stars 1.28k forks source link

Input prompt flickers while waiting for validation function #1407

Open anchenyi opened 1 month ago

anchenyi commented 1 month ago

I use the input prompt from the @inquirer/prompts package to handle user input. However, I noticed that the built-in waiting spinner keeps flickering while the validation function is processing. How can I avoid this issue? Thanks.

Terminal: Windows Powershell @inquirer/prompts: 5.0.4 node: v16.20.2

Typescipt Codes to reproduce

import { input } from "@inquirer/prompts";
const validate = async (input: string) => {
    await new Promise(resolve => setTimeout(resolve, 5000));
    return true
};

(async () => {
    let message: string =  "select your message"
    let defaultValue = "1"

    const answer = await input({
        message,
        default: defaultValue,
        validate: validate,
        });
    console.log(`input value:${answer}`);
})();

https://github.com/SBoudrias/Inquirer.js/assets/162104711/bb6e98c5-07bd-4180-968d-d77051b24769

SBoudrias commented 1 month ago

For reference, here's another fix to a similar issue that was happening in other cases: https://github.com/SBoudrias/Inquirer.js/pull/1379

SBoudrias commented 1 week ago

Pushed a little perf improvement, I'd appreciate if you could test it out and let me know if it's any better for you. I personally don't encounter this flickering in any mac OS prompt - so I'm having a hard time diving deeper into the issue.

anchenyi commented 10 hours ago

hi @SBoudrias Thanks for the response. I checked the latest @inquirer/prompts v5.1.0, the flickers still exist.