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: Proposal for better repl #8195

Closed
princejwesley opened this issue Aug 20, 2016 · 20 comments
Closed

repl: Proposal for better repl #8195

princejwesley opened this issue Aug 20, 2016 · 20 comments
Assignees
Labels
discuss Issues opened for discussions and feedbacks. feature request Issues that request new features to be added to Node.js. repl Issues and PRs related to the REPL subsystem.

Comments

@princejwesley
Copy link
Contributor

princejwesley commented Aug 20, 2016

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/^C the 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
  • No welcome message (it helps to see version number)

Proposal

  • Welcome message with version and help guide
  • Differentiate 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.
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

@princejwesley princejwesley added the discuss Issues opened for discussions and feedbacks. label Aug 20, 2016
@mscdex mscdex added the repl Issues and PRs related to the REPL subsystem. label Aug 20, 2016
@yorkie
Copy link
Contributor

yorkie commented Aug 20, 2016

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.

@princejwesley
Copy link
Contributor Author

princejwesley commented Aug 20, 2016

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

@yorkie
Copy link
Contributor

yorkie commented Aug 20, 2016

@princejwesley it depends on what shell you are using IMO, it doesn't work at iTerm. Let me verify it again later :)

@mscdex
Copy link
Contributor

mscdex commented Aug 20, 2016

What about just enter and shift+enter or similar for execute and continue respectively?

@princejwesley
Copy link
Contributor Author

princejwesley commented Aug 20, 2016

@yorkie I use same iTerm 😄 . See control characters and here

@princejwesley
Copy link
Contributor Author

@mscdex Terminal emits same value for both shift + enter and enter.

@yorkie
Copy link
Contributor

yorkie commented Aug 20, 2016

Sorry @princejwesley you are right, it works :-)

@jasnell jasnell added the feature request Issues that request new features to be added to Node.js. label Aug 22, 2016
@jasnell
Copy link
Member

jasnell commented Aug 26, 2016

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.

@princejwesley
Copy link
Contributor Author

@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 😄 .

@jasnell
Copy link
Member

jasnell commented Aug 26, 2016

Ok, I'm good with that then.

@princejwesley
Copy link
Contributor Author

@nodejs/collaborators if there is no objection, I'll start work on it

@DemiMarie
Copy link

What about requiring that, for an expression to be submitted, it must be followed by 2 newlines or by a semicolon?

@Trott
Copy link
Member

Trott commented Jul 10, 2017

@princejwesley Are you still working on this?

@princejwesley
Copy link
Contributor Author

@Trott it's implemented long ago

@Trott
Copy link
Member

Trott commented 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
Copy link
Contributor Author

@Trott sure, I'll do

@lance
Copy link
Member

lance commented Sep 14, 2017

Since #9601 has been closed, is there any reason for this to remain open?

@jasnell
Copy link
Member

jasnell commented Sep 14, 2017

If @princejwesley wants to keep working on this, I see no reason not to keep it open.

@jasnell
Copy link
Member

jasnell commented Sep 14, 2017

heh... that answers that then. Really do appreciate the work and effort on this @princejwesley

@lance
Copy link
Member

lance commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Issues opened for discussions and feedbacks. feature request Issues that request new features to be added to Node.js. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

No branches or pull requests

7 participants