Skip to content
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

Closed
wants to merge 8 commits into from
Closed

Conversation

BridgeAR
Copy link
Member

@BridgeAR BridgeAR 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

@BridgeAR BridgeAR requested review from jasnell and targos May 7, 2020 16:28
@nodejs-github-bot nodejs-github-bot added the repl Issues and PRs related to the REPL subsystem. label May 7, 2020
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 <ruben@bridgewater.de>
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 <ruben@bridgewater.de>
@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 <ruben@bridgewater.de>
@nodejs-github-bot

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 <ruben@bridgewater.de>
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 <ruben@bridgewater.de>
@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
Member Author

BridgeAR commented May 9, 2020

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

@BridgeAR BridgeAR 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

targos commented May 10, 2020

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
Member Author

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 <ruben@bridgewater.de>
@BridgeAR
Copy link
Member Author

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

@nodejs-github-bot
Copy link
Collaborator

@BridgeAR BridgeAR 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 <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
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 <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
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
Refs: nodejs#33238
Refs: nodejs#33282

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
ExE-Boss added a commit to ExE-Boss/node that referenced this pull request Feb 4, 2021
Refs: nodejs#33238
Refs: nodejs#33282

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
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 <duhamelantoine1995@gmail.com>

PR-URL: nodejs#37178
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
danielleadams pushed a commit that referenced this pull request Feb 16, 2021
Refs: #33238
Refs: #33282

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: #37178
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
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 <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
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 <duhamelantoine1995@gmail.com>

PR-URL: nodejs#37178
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
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 <duhamelantoine1995@gmail.com>

PR-URL: nodejs#37178
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
targos pushed a commit that referenced this pull request Sep 1, 2021
Refs: #33238
Refs: #33282

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: #37178
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. repl Issues and PRs related to the REPL subsystem. semver-minor PRs 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