From a0e0b3a845f617b5d2a655c218ac6706b35384a9 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 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. --- 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 a030da7b4df460..ef2a5a7f9604ff 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -596,8 +596,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 9fda04406ecd87..2868622d435646 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -212,8 +212,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;