mirror of https://github.com/nodejs/node.git
Ctrl+W support for the REPL
FWIW, command-line style (delete back to whitespace) would be: leading = leading.replace(/\S+\s*$/, '');pull/22966/head
parent
cf4b5fc52a
commit
5330fea954
|
@ -331,6 +331,17 @@ Interface.prototype._ttyWrite = function (b) {
|
|||
this._historyNext();
|
||||
break;
|
||||
|
||||
case 23: // control-w, delete backwards to a word boundary
|
||||
if (this.cursor !== 0) {
|
||||
var leading = this.line.slice(0, this.cursor);
|
||||
var match = leading.match(/\s?((\W+|\w+)\s*)$/);
|
||||
leading = leading.slice(0, leading.length - match[1].length);
|
||||
this.line = leading + this.line.slice(this.cursor, this.line.length);
|
||||
this.cursor = leading.length;
|
||||
this._refreshLine();
|
||||
}
|
||||
break;
|
||||
|
||||
case 9: // tab, completion
|
||||
if (this.completer) {
|
||||
this._tabComplete();
|
||||
|
|
Loading…
Reference in New Issue