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.

PR-URL: https://github.com/nodejs/node/pull/31259
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Ruben Bridgewater authored and Rich Trott committed 2020-01-10 04:35:37 -08:00
1 parent eca22d5565
commit 95303629a4
2 files changed
+5 -3

No files matched your search

+3 -2
View File
@@ -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.
+2 -1
View File
@@ -213,8 +213,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;