-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
repl: improve repl preview #33282
repl: improve repl preview #33282
Conversation
This aligns the REPL preview with the one used in the Chrome DevTools console. It will now preview the output for the input including the completion suffix as input. When pressing enter while previewing such data, it will automatically insert the suffix before evaluating the input. When pressing escape, that behavior is deactivated until the input is changed. Signed-off-by: Ruben Bridgewater <[email protected]>
This aligns the behavior with the one in the Firefox console. It will visualize ReferenceErrors in case the input has no possible completion and no buffered input. That way typos can already be highlighted before being evaluated. Signed-off-by: Ruben Bridgewater <[email protected]>
e8bcc7c
to
7821dd2
Compare
This comment has been minimized.
This comment has been minimized.
This replaces the internally used hard coded Node.js core module list with the actual internal existent modules. That way all modules are automatically picked up instead of having to update the list manually. This currently only applies to the REPL and to the Node.js `eval` functionality (User passed `-e` or `--eval` arguments to Node without `-i` or `--interactive`). Signed-off-by: Ruben Bridgewater <[email protected]>
585ca68
to
c410d68
Compare
This comment has been minimized.
This comment has been minimized.
This simplifies the test a bit by removing duplicated code and by focusing the reader on the passed through module. Signed-off-by: Ruben Bridgewater <[email protected]>
This improves the autocompletion for require calls. It had multiple small issues so far. Most important: it won't suggest completions for require statements that are fully written out. Second, it'll detect require calls that have whitespace behind the opening bracket. Third, it makes sure node modules are detected as such instead of only suggesting them as folders. Last, it adds suggestions for input that starts with backticks. Fixes: nodejs#33238 Signed-off-by: Ruben Bridgewater <[email protected]>
c410d68
to
00cd4d8
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@nodejs/repl PTAL. This could use some reviews. |
I really like the behavior with the first commit! I do not understand how the second one works, though (repl: show reference errors during preview). I tried to start node with |
@targos thanks, I did not include a check to detect |
This adds support for `--use-strict`. Signed-off-by: Ruben Bridgewater <[email protected]>
I added support for |
88c5344
to
abc2bda
Compare
Notable changes: async_hooks: * (SEMVER-MINOR) move PromiseHook handler to JS (Stephen Belanger) #32891 cli: * (SEMVER-MINOR) add `--trace-atomics-wait` flag (Anna Henningsen) #33292 fs: * (SEMVER-MINOR) add .ref() and .unref() methods to watcher classes (rickyes) #33134 http: * (SEMVER-MINOR) expose http.validate-header-name/value (osher) #33119 repl: * (SEMVER-MINOR) deprecate repl._builtinLibs (Ruben Bridgewater) #33294 * (SEMVER-MINOR) deprecate repl.inputStream and repl.outputStream (Ruben Bridgewater) #33294 * (SEMVER-MINOR) show reference errors during preview (Ruben Bridgewater) #33282 * (SEMVER-MINOR) improve repl preview (Ruben Bridgewater) #33282 src: * add support for TLA (Gus Caplan) #30370 PR-URL: TODO
Notable changes: async_hooks: * (SEMVER-MINOR) move PromiseHook handler to JS (Stephen Belanger) #32891 cli: * (SEMVER-MINOR) add `--trace-atomics-wait` flag (Anna Henningsen) #33292 fs: * (SEMVER-MINOR) add .ref() and .unref() methods to watcher classes (rickyes) #33134 http: * (SEMVER-MINOR) expose http.validate-header-name/value (osher) #33119 repl: * (SEMVER-MINOR) deprecate repl._builtinLibs (Ruben Bridgewater) #33294 * (SEMVER-MINOR) deprecate repl.inputStream and repl.outputStream (Ruben Bridgewater) #33294 * (SEMVER-MINOR) show reference errors during preview (Ruben Bridgewater) #33282 * (SEMVER-MINOR) improve repl preview (Ruben Bridgewater) #33282 src: * add support for TLA (Gus Caplan) #30370 PR-URL: #33452
Is this something we want to backport to v12.x? Based on the various commits referencing this PR I'm imagining it might need to be a couple different PRs all at once. |
@BridgeAR @jasnell @targos This uses blocking operations for autocompletion. Can we revert this, or fix that? It’s extremely annoying that the repl hangs for an indefinite amount of time when you type |
It’s not okay for the REPL to be blocked for multiple seconds after entering `require('` because the completion is performing blocking fs operations on potentially huge directories. Turning the REPL completion function asynchronous would be the right thing to do here, but unfortunately the way the code is structured doesn’t play well with that (in particular, it breaks the preview feature). Therefore, disable these blocking calls by default. Refs: nodejs#33282 (comment)
Since there’s been no reply, I’ve opened #36564 to disable this by default. |
It’s not okay for the REPL to be blocked for multiple seconds after entering `require('` because the completion is performing blocking fs operations on potentially huge directories. Turning the REPL completion function asynchronous would be the right thing to do here, but unfortunately the way the code is structured doesn’t play well with that (in particular, it breaks the preview feature). Therefore, disable these blocking calls by default. Refs: #33282 (comment) PR-URL: #36564 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
It’s not okay for the REPL to be blocked for multiple seconds after entering `require('` because the completion is performing blocking fs operations on potentially huge directories. Turning the REPL completion function asynchronous would be the right thing to do here, but unfortunately the way the code is structured doesn’t play well with that (in particular, it breaks the preview feature). Therefore, disable these blocking calls by default. Refs: #33282 (comment) PR-URL: #36564 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Refs: nodejs#33238 Refs: nodejs#33282 Co-authored-by: Antoine du Hamel <[email protected]>
Refs: nodejs#33238 Refs: nodejs#33282 Co-authored-by: Antoine du Hamel <[email protected]>
Refs: nodejs#33238 Refs: nodejs#33282 Co-authored-by: Antoine du Hamel <[email protected]> PR-URL: nodejs#37178 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Refs: #33238 Refs: #33282 Co-authored-by: Antoine du Hamel <[email protected]> PR-URL: #37178 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Rich Trott <[email protected]>
It’s not okay for the REPL to be blocked for multiple seconds after entering `require('` because the completion is performing blocking fs operations on potentially huge directories. Turning the REPL completion function asynchronous would be the right thing to do here, but unfortunately the way the code is structured doesn’t play well with that (in particular, it breaks the preview feature). Therefore, disable these blocking calls by default. Refs: #33282 (comment) PR-URL: #36564 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
Refs: nodejs#33238 Refs: nodejs#33282 Co-authored-by: Antoine du Hamel <[email protected]> PR-URL: nodejs#37178 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Refs: nodejs#33238 Refs: nodejs#33282 Co-authored-by: Antoine du Hamel <[email protected]> PR-URL: nodejs#37178 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Refs: #33238 Refs: #33282 Co-authored-by: Antoine du Hamel <[email protected]> PR-URL: #37178 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Please check the commit messages for details.
Fixes: #33238
@nodejs/repl
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes