Promise.all([ completeLine(inspectedLine, true), getPreview(inspectedLine), ]) .then(([completion, preview]) => { if (rl.line !== inspectedLine) { return; } if (completion && completion.completions.length > 0) { if (completion.fillable) { ([completionCache] = completion.completions); } process.stdout.cursorTo(PROMPT.length + rl.line.length); process.stdout.write(chalk.grey(completion.completions[0])); } if (preview) { process.stdout.write(`\n${chalk.grey(preview.slice(0, process.stdout.columns - 1))}`); process.stdout.moveCursor(0, -1); } if (completion || preview) { process.stdout.cursorTo(PROMPT.length + rl.cursor); } }) .catch(() => {});