From 2b0ad131ec5ec7e601bf0883322441b6b9832caa Mon Sep 17 00:00:00 2001 From: meixg Date: Sat, 19 Feb 2022 21:59:07 +0800 Subject: [PATCH] repl: remove preview when press escape Fix: https://github.com/nodejs/node/issues/42040 --- lib/repl.js | 4 +++- test/parallel/test-repl-history-navigation.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index 6621a4d9e8131e..eb9152d9ce0266 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -986,7 +986,9 @@ function REPLServer(prompt, clearPreview(key); if (!reverseSearch(d, key)) { ttyWrite(d, key); - showPreview(); + if (key.name !== 'escape') { + showPreview(); + } } return; } diff --git a/test/parallel/test-repl-history-navigation.js b/test/parallel/test-repl-history-navigation.js index 527cf235bddd21..29cb7816f0feb0 100644 --- a/test/parallel/test-repl-history-navigation.js +++ b/test/parallel/test-repl-history-navigation.js @@ -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',