From bf30154d195fe4fb3cb8ba711117290af765777c Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 5 Dec 2019 14:41:49 +0100 Subject: [PATCH] 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 8d5fa87f2c3f17..be3c0b8c52e2ab 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -520,6 +520,9 @@ with REPL instances programmatically.