This is my idea/wish to address Node.js repl related issues.
.break/^C the expression to continue.js
let echo = e => e;
let x;
x = echo(2); // 2
x = echo // both echo and echo\n(2) are completely valid expression
(2) // 2
execute & continue actions^M or enter key to execute the command (current behavior)^J to continue (Hand over the problem to user, let user decides it) building multiline expression.> 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
There are a consideration: introducing the combining types like ^M or ^J might be unreasonable conflict with the shell itself.
For example, in my iTerm.app, ^M would close the current window.
@yorkie Tried cmd + M or ctrl + M(^M) ? if we are in repl context, I don't see any conflict. ^M for execute command is an existing behaviour.
@princejwesley it depends on what shell you are using IMO, it doesn't work at iTerm. Let me verify it again later :)
What about just enter and shift+enter or similar for execute and continue respectively?
@yorkie I use same iTerm 馃槃 . See control characters and here
@mscdex Terminal emits same value for both shift + enter and enter.
Sorry @princejwesley you are right, it works :-)
This makes sense. I do like the idea of ^J _or_ Shift-Enter to continue. That would pair nicely with ^M _or_ Enter to execute.
@jasnell We can't capture Shift-Enter. Terminal emits same ^M for Enter and Shift-Enter(terminal ignores ctrl, shift or meta keys when paired with Enter)
~ 馃檲 鈧筤M (ctrl+v, enter)
~ 馃檲 鈧筤M (ctrl+v, shift+enter)
For me, ^J sounds like jump to next line 馃槃 .
Ok, I'm good with that then.
@nodejs/collaborators if there is no objection, I'll start work on it
What about requiring that, for an expression to be submitted, it must be followed by 2 newlines or by a semicolon?
@princejwesley Are you still working on this?
@Trott it's implemented long ago
@princejwesley You mean https://github.com/nodejs/node/pull/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?
@Trott sure, I'll do
Since #9601 has been closed, is there any reason for this to remain open?
If @princejwesley wants to keep working on this, I see no reason not to keep it open.
heh... that answers that then. Really do appreciate the work and effort on this @princejwesley
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.
Most helpful comment
@nodejs/collaborators if there is no objection, I'll start work on it