From ee40b67413a8de067f6f3c698acaed95f6a0d0c4 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 8 Jan 2020 11:54:51 +0100 Subject: [PATCH] repl: change preview default in case of custom eval functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Custom eval functions might have a very different behavior than the current implementation and having a preview in such case might be confusing. This changes the preview default to `false` in case a custom eval function is used. It is still possible to opt into using the previews in case that's still desirable. PR-URL: https://github.com/nodejs/node/pull/31259 Reviewed-By: Michaƫl Zasso Reviewed-By: Anto Aravinth Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan Reviewed-By: Rich Trott Reviewed-By: James M Snell --- doc/api/repl.md | 5 +++-- lib/repl.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/api/repl.md b/doc/api/repl.md index 70f77af48490a3..b526096692a0a0 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -597,8 +597,9 @@ changes: `SIGINT` is received, such as when `Ctrl+C` is pressed. This cannot be used together with a custom `eval` function. **Default:** `false`. * `preview` {boolean} Defines if the repl prints autocomplete and output - previews or not. **Default:** `true`. If `terminal` is falsy, then there are - no previews and the value of `preview` has no effect. + previews or not. **Default:** `true` with the default eval function and + `false` in case a custom eval function is used. If `terminal` is falsy, then + there are no previews and the value of `preview` has no effect. * Returns: {repl.REPLServer} The `repl.start()` method creates and starts a [`repl.REPLServer`][] instance. diff --git a/lib/repl.js b/lib/repl.js index a86cba0624b6dc..e4a7e9474ee054 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -214,8 +214,9 @@ function REPLServer(prompt, } } + // TODO(devsnek): Add a test case for custom eval functions. const preview = options.terminal && - (options.preview !== undefined ? !!options.preview : true); + (options.preview !== undefined ? !!options.preview : !eval_); this.inputStream = options.input; this.outputStream = options.output;