Repository navigation
REPL aggressively uses wrong autocomplete on ENTER #42040
Description
Activity
- addedreplIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
on Feb 17, 2022 I am able to reproduce this in both v16 latest and master. I think the ask here is reasonable and this isn't really a hard fix but I'm not sure if it's intentional.
@nodejs/repl @BridgeAR wdyt?
@meixg since you committed there in the past and it doesn't look like a hard fix, want to take a look at this too?
@meixg since you committed there in the past and it doesn't look like a hard fix, want to take a look at this too?
Yes, with pleasure :)
Reacted by Benjamin GruenbaumI made a PR may fix this: #42053
But there may be two more things we can improve:
- The preview of
var add = x => y => x+yshould be justy, notyield. The problem here is that we currently implement autocomplete based on regular expressions, so the context information invar add = x => y => x+yis lost. Maybe we should use a parser repl: #41690 REPL gives wrong autocomplete on literals #41883 (comment). - There is a 500ms delay after pressing
ESCAPE: https://github.com/nodejs/node/blob/master/lib/internal/readline/emitKeypressEvents.js#L67, if we press another key afterESCAPEwithin 500ms, theESCAPEwill be ignored.
Visual feedback (PR above) can help a lot, but I wonder if we can find a way to remove this delay completely.
Reacted by Benjamin Gruenbaum- The preview of
Thanks for working on this, @meixg . But I want to clarify that the issue I raise here is not related to "preview" (the advance evaluation of the line I'm still typing), but rather "autocomplete", particularly preferring it's own suggestion without confirmation from me.
I like autocomplete, when it doesn't get in my way.
Preview, however, is... uncompelling.
Thanks for working on this, @meixg . But I want to clarify that the issue I raise here is not related to "preview" (the advance evaluation of the line I'm still typing), but rather "autocomplete", particularly preferring it's own suggestion without confirmation from me.
I like autocomplete, when it doesn't get in my way.
Preview, however, is... uncompelling.
I know what you mean, see 80913e6, when you press
ENTER, is actually the 'preview' part that is used.With the PR above, it will behave more like the Chrome DevTools console.
I agree Chrome Devtools has a good usability model to emulate. I'll give this observation, then leave it in your capable hands:
In Devtools, when I'm at the point of having an outstanding suggestion, my first ENTER accepts the suggestion, and a second ENTER submits the line. In Node REPL, a single ENTER does both of these.
I agree Chrome Devtools has a good usability model to emulate. I'll give this observation, then leave it in your capable hands:
In Devtools, when I'm at the point of having an outstanding suggestion, my first ENTER accepts the suggestion, and a second ENTER submits the line. In Node REPL, a single ENTER does both of these.
Yeah, there is a different behavior too, I can try to improve that.
- added a commit that references this issue
on Feb 23, 2022 - added a commit that references this issue
on Mar 7, 2022 - added 4 commits that reference this issue
on Apr 21, 2022
Version
v16.13.0
Platform
Microsoft Windows NT 10.0.19044.0 x64
Subsystem
repl
What steps will reproduce the bug?
When typing into the REPL, autocomplete often predicts identifiers or keywords even when the typed characters are valid. When I hit ENTER (no TAB to accept), then the REPL chooses to use its prediction rather than what I actually typed.
For example, typing
then hitting ENTER
It's infuriating.
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
I expect to be able to hit TAB to accept the prediction. If I continue to type something else then autocomplete should revise its prediction. If I hit enter, autocomplete should realize its services are no longer needed.
What do you see instead?
followed by ENTER results in
Additional information
No response