Skip to content

Commit b9b044b

Browse files
BridgeARMylesBorins
authored andcommitted
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: #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>
1 parent 0271457 commit b9b044b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

doc/api/repl.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,9 @@ changes:
597597
`SIGINT` is received, such as when `Ctrl+C` is pressed. This cannot be used
598598
together with a custom `eval` function. **Default:** `false`.
599599
* `preview` {boolean} Defines if the repl prints autocomplete and output
600-
previews or not. **Default:** `true`. If `terminal` is falsy, then there are
601-
no previews and the value of `preview` has no effect.
600+
previews or not. **Default:** `true` with the default eval function and
601+
`false` in case a custom eval function is used. If `terminal` is falsy, then
602+
there are no previews and the value of `preview` has no effect.
602603
* Returns: {repl.REPLServer}
603604

604605
The `repl.start()` method creates and starts a [`repl.REPLServer`][] instance.

lib/repl.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,9 @@ function REPLServer(prompt,
213213
}
214214
}
215215

216+
// TODO(devsnek): Add a test case for custom eval functions.
216217
const preview = options.terminal &&
217-
(options.preview !== undefined ? !!options.preview : true);
218+
(options.preview !== undefined ? !!options.preview : !eval_);
218219

219220
this.inputStream = options.input;
220221
this.outputStream = options.output;

0 commit comments

Comments
 (0)