From 8bba55aed4d3345f69aa3a4da286b66d6130e077 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 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). Fixes: https://github.com/nodejs/node/issues/20977 --- doc/api/repl.md | 6 + lib/internal/repl/utils.js | 169 +++++++++++++++++- 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, 444 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 967336710ce3a1..e853086cb21a8a 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -510,6 +510,10 @@ with REPL instances programmatically.