Skip to content

Conversation

@BridgeAR
Copy link
Member

@BridgeARBridgeAR commented May 7, 2020

Please check the commit messages for details.

Fixes: #33238

@nodejs/repl

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@BridgeARBridgeAR requested review from jasnell and targosMay 7, 2020 16:28
@nodejs-github-botnodejs-github-bot added the repl Issues and PRs related to the REPL subsystem. label May 7, 2020
BridgeAR added 2 commits May 7, 2020 18:44
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]>
@BridgeARBridgeARforce-pushed the improve-repl-preview branch from e8bcc7c to 7821dd2CompareMay 7, 2020 16:44
@nodejs-github-bot

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]>
@BridgeARBridgeARforce-pushed the improve-repl-preview branch from 585ca68 to c410d68CompareMay 7, 2020 19:01
@nodejs-github-bot

This comment has been minimized.

BridgeAR added 2 commits May 8, 2020 01:35
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]>
@BridgeARBridgeARforce-pushed the improve-repl-preview branch from c410d68 to 00cd4d8CompareMay 7, 2020 23:35
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@BridgeAR
Copy link
MemberAuthor

@nodejs/repl PTAL. This could use some reviews.

@BridgeARBridgeAR added the semver-minor PRs that contain new features and should be released in the next minor version. label May 10, 2020
@targos
Copy link
Member

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 --use-strict, which throws ReferenceError for bad assignments but the behavior of the REPL doesn't change.

@BridgeAR
Copy link
MemberAuthor

BridgeAR commented May 11, 2020

@targos thanks, I did not include a check to detect --use-strict. That is actually a V8 feature and not from Node.js. As such we lack any documentation of it and we implemented a own way to use the strict mode with the REPL: NODE_REPL_MODE = 'strict'.

This adds support for `--use-strict`. Signed-off-by: Ruben Bridgewater <[email protected]>
@BridgeAR
Copy link
MemberAuthor

I added support for --use-strict as well, since it does seem to be useful for the REPL.

@BridgeARBridgeARforce-pushed the improve-repl-preview branch from 88c5344 to abc2bdaCompareMay 11, 2020 12:23
@nodejs-github-bot
Copy link
Collaborator

@BridgeARBridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 11, 2020
@nodejs-github-bot
Copy link
Collaborator

codebytere added a commit that referenced this pull request May 19, 2020
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
codebytere added a commit that referenced this pull request May 19, 2020
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
@MylesBorins
Copy link
Contributor

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.

@addaleax
Copy link
Member

@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 require(' when your node_modules directory is large. It also doesn’t seem necessary, given that the autocomplete API is designed to be asynchronous.

addaleax added a commit to addaleax/node that referenced this pull request Dec 18, 2020
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)
@addaleax
Copy link
Member

Since there’s been no reply, I’ve opened #36564 to disable this by default.

addaleax added a commit that referenced this pull request Dec 21, 2020
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]>
targos pushed a commit that referenced this pull request Dec 21, 2020
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]>
ExE-Boss added a commit to ExE-Boss/node that referenced this pull request Feb 2, 2021
ExE-Boss added a commit to ExE-Boss/node that referenced this pull request Feb 2, 2021
ExE-Boss added a commit to ExE-Boss/node that referenced this pull request Feb 4, 2021
ExE-Boss added a commit to ExE-Boss/node that referenced this pull request Feb 4, 2021
Trott pushed a commit to ExE-Boss/node that referenced this pull request Feb 6, 2021
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]>
danielleadams pushed a commit that referenced this pull request Feb 16, 2021
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]>
danielleadams pushed a commit that referenced this pull request Apr 29, 2021
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]>
targos pushed a commit to targos/node that referenced this pull request Aug 8, 2021
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]>
targos pushed a commit to targos/node that referenced this pull request Aug 8, 2021
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]>
targos pushed a commit that referenced this pull request Sep 1, 2021
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]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.replIssues and PRs related to the REPL subsystem.semver-minorPRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repl: Extra / on completion after require

6 participants

@BridgeAR@nodejs-github-bot@targos@MylesBorins@addaleax@jasnell