From 6bdf8d106009e4ed0f3c323d0f0874a51acc8e08 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 5 Dec 2019 14:41:49 +0100 Subject: repl: support previews by eager evaluating input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds input previews by using the inspectors eager evaluation functionality. It is implemented as additional line that is not counted towards the actual input. In case no colors are supported, it will be visible as comment. Otherwise it's grey. It will be triggered on any line change. It is heavily tested against edge cases and adheres to "dumb" terminals (previews are deactived in that case). PR-URL: https://github.com/nodejs/node/pull/30811 Fixes: https://github.com/nodejs/node/issues/20977 Reviewed-By: Yongsheng Zhang Reviewed-By: Anto Aravinth Reviewed-By: Michaƫl Zasso --- doc/api/repl.md | 5 + lib/internal/repl/utils.js | 168 +++++++++++++++++++++++++- lib/repl.js | 18 ++- test/parallel/test-repl-history-navigation.js | 28 ++++- test/parallel/test-repl-multiline.js | 62 ++++++---- test/parallel/test-repl-preview.js | 131 ++++++++++++++++++++ test/parallel/test-repl-top-level-await.js | 101 ++++++++++------ 7 files changed, 442 insertions(+), 71 deletions(-) create mode 100644 test/parallel/test-repl-preview.js diff --git a/doc/api/repl.md b/doc/api/repl.md index 967336710c..21f5193c12 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -510,6 +510,9 @@ with REPL instances programmatically.