Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b9b044b

Browse filesBrowse 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
Copy full SHA for b9b044b

File tree

Expand file treeCollapse file tree

2 files changed

+5
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-3
lines changed
Open diff view settings
Collapse file

‎doc/api/repl.md‎

Copy file name to clipboardExpand all lines: doc/api/repl.md
+3-2Lines changed: 3 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
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.
Collapse file

‎lib/repl.js‎

Copy file name to clipboardExpand all lines: lib/repl.js
+2-1Lines changed: 2 additions & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.