From d6b1a4a23502ca2beaa99e2e8a7e8b7812022b01 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 PR-URL: https://github.com/nodejs/node/pull/42053 Fixes: https://github.com/nodejs/node/issues/42040 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Rich Trott Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Mestery Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- 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',