Ctrl+W support for the REPL

FWIW, command-line style (delete back to whitespace) would be:
    leading = leading.replace(/\S+\s*$/, '');
pull/22966/head
Trent Mick 2010-09-03 21:53:53 -07:00 committed by Ryan Dahl
parent cf4b5fc52a
commit 5330fea954
1 changed files with 11 additions and 0 deletions

View File

@ -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();