Repository navigation
Closed
Labels
discussIssues opened for discussion and feedback.Issues opened for discussion and feedback.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
Description
This is my idea/wish to address Node.js repl related issues.
-
Automatic multiline command mode has serious issues.
- Recoverable error guess is based on error message emitted by v8(vm specific) engine
(we may have to fix the code if vm emits different error string in next release) - False positives. We have to
.break/^Cthe expression to continue. - We can't reliably deduce the end of expression even if we build an incremental JS parser.
let echo = e => e; let x; x = echo(2); // 2 x = echo // both echo and echo\n(2) are completely valid expression (2) // 2
- Recoverable error guess is based on error message emitted by v8(vm specific) engine
-
No welcome message (it helps to see version number)
Proposal
- Welcome message with version and help guide
- Differentiate
execute&continueactions^Mor enter key to execute the command (current behavior)^Jto continue (Hand over the problem to user, let user decides it) building multiline expression.
Welcome message template
> node
Welcome to Node.js <<version>> (<<vm name>> VM, <<vm version>>)
Type ^M or enter to execute, ^J to continue, ^C to exit
Or try .help for help, more at https://nodejs.org/dist/v<<version>>/docs/api/repl.html
>e.g.
> node
Welcome to Node.js 6.4.0 (v8 VM, 5.0.71.60)
Type ^M or enter to execute, ^J to continue, ^C to exit
Or try .help for help, more at https://nodejs.org/dist/v6.4.0/docs/api/repl.html
>@nodejs/collaborators, I am happy to implement this if there is no objection
Note : Current system executes code when ^M, ^J or enter pressed. ^I or tab for code completion
Metadata
Metadata
Assignees
Labels
discussIssues opened for discussion and feedback.Issues opened for discussion and feedback.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
Activity
princejwesley commentedon Aug 20, 2016
@yorkie Tried
cmd+Morctrl+M(^M) ? if we are in repl context, I don't see any conflict.^Mfor execute command is an existing behaviour.mscdex commentedon Aug 20, 2016
What about just enter and shift+enter or similar for execute and continue respectively?
princejwesley commentedon Aug 20, 2016
@yorkie I use same
iTerm😄 . See control characters and hereprincejwesley commentedon Aug 20, 2016
@mscdex Terminal emits same value for both
shift + enterandenter.jasnell commentedon Aug 26, 2016
This makes sense. I do like the idea of
^JorShift-Enterto continue. That would pair nicely with^MorEnterto execute.princejwesley commentedon Aug 26, 2016
@jasnell We can't capture
Shift-Enter. Terminal emits same^MforEnterandShift-Enter(terminal ignoresctrl,shiftor meta keys when paired withEnter)For me,
^Jsounds like jump to next line 😄 .jasnell commentedon Aug 26, 2016
Ok, I'm good with that then.
princejwesley commentedon Aug 31, 2016
@nodejs/collaborators if there is no objection, I'll start work on it
DemiMarie commentedon Sep 16, 2016
What about requiring that, for an expression to be submitted, it must be followed by 2 newlines or by a semicolon?
Trott commentedon Jul 10, 2017
@princejwesley Are you still working on this?
princejwesley commentedon Jul 11, 2017
@Trott it's implemented long ago
Trott commentedon Jul 11, 2017
@princejwesley You mean #9601? Can you rebase against master and hopefully some of the people that +1'ed it can give it an official LGTM and we can get it landed?
princejwesley commentedon Jul 11, 2017
@Trott sure, I'll do
lance commentedon Sep 14, 2017
Since #9601 has been closed, is there any reason for this to remain open?
jasnell commentedon Sep 14, 2017
If @princejwesley wants to keep working on this, I see no reason not to keep it open.
jasnell commentedon Sep 14, 2017
heh... that answers that then. Really do appreciate the work and effort on this @princejwesley
lance commentedon Sep 14, 2017
Well, tbh, I closed #9601 myself. But based on feedback received in that PR, and on my subsequent PRs that pick up some of that work, I think it would take a big effort for #9160 as it is to land. Hope I wasn't being premature about that.