repl: remove preview when press escape

Fix: https://github.com/nodejs/node/issues/42040

PR-URL: https://github.com/nodejs/node/pull/42053
Fixes: https://github.com/nodejs/node/issues/42040
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
meixg 2022-02-19 21:59:07 +08:00 committed by Rich Trott
parent 19bf6c59ab
commit dc28d6315d
2 changed files with 4 additions and 2 deletions

View File

@ -986,7 +986,9 @@ function REPLServer(prompt,
clearPreview(key);
if (!reverseSearch(d, key)) {
ttyWrite(d, key);
showPreview();
if (key.name !== 'escape') {
showPreview();
}
}
return;
}

View File

@ -393,7 +393,7 @@ const tests = [
// 10. Word right. Cleanup
'\x1B[0K', '\x1B[3G', '\x1B[7C', ' // n', '\x1B[10G',
// 11. ESCAPE
'\x1B[0K', ' // n', '\x1B[10G', '\x1B[0K',
'\x1B[0K',
// 12. ENTER
'\r\n',
'Uncaught ReferenceError: functio is not defined\n',