nodejs / repl

REPL rewrite for Node.js ✨🐢🚀✨
MIT License
177 stars 25 forks source link

[feature request] Allow multiline up arrow (like Chrome Devtools) #45

Open Jamesernator opened 4 years ago

Jamesernator commented 4 years ago

Currently node's repl is pretty painful when dealing with multiline expressions/statements like:

Point = class {
  x; y;
  constructor(x, y) {
    this.x = x;
    this.yy = y;
  }
}

After entering such an expression often you'll notice is has an error somewhere, however to fix the error it'll generally involve going back to each line in order and entering it again e.g.:

https://1drv.ms/v/s!AqOK_5mhCFkag7VLMCfWVeCX_IFTtA?e=I6ikhd

Now chrome devtools/ndb has a nice feature in that a single up arrow goes to the last set of statements evaluated and be navigated entirely using a keyboard using Enter and Shift-Enter to navigate e.g.:

https://1drv.ms/v/s!AqOK_5mhCFkag7VMdWd_CJqhe_X9Ig?e=Gm86DL

I'd like to propose doing the same with Node's REPL.

It's a lot easier to work with as you don't need to do a bunch of up-arrows to re-enter every single line of the previous expression in order to fix it. The current behavior is also pretty error prone, especially for functions where you might accidentally re-order statements creating new errors and hence having to redo them all over again.