Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
92214cf
test: remove obsolete harmony flags
chrisdickinson May 5, 2015
dc94349
deps: update v8 to 4.3.61.21
chrisdickinson May 5, 2015
cba302f
doc: update v8 flags in man page
targos May 14, 2015
263b454
Revert "dns: remove AI_V4MAPPED hint flag on FreeBSD"
cjihrig Apr 29, 2015
d6a97eb
net: do not set V4MAPPED on FreeBSD
Mar 2, 2015
2a97fc8
deps: backport 7b24219346 from v8 upstream
rvagg May 27, 2015
804f3a0
buffer: allow ARGS_THIS to accept a name
trevnorris May 26, 2015
d6e8e37
buffer: implement Uint8Array backed Buffer
trevnorris May 26, 2015
f6d74da
buffer: finish implementing FreeCallback
trevnorris Jun 1, 2015
833377c
buffer: switch to using Maybe<T> API
trevnorris Jun 2, 2015
f41282f
buffer: switch API to return MaybeLocal<T>
trevnorris Jun 2, 2015
194f63e
buffer: make additional changes to native API
trevnorris Jun 2, 2015
c0d46a1
crypto: remove kMaxLength on randomBytes()
trevnorris Jun 2, 2015
450ba88
vm: fix property descriptors of sandbox properties
domenic May 22, 2015
5ca9579
vm: remove unnecessary access checks
domenic May 23, 2015
7767b9d
vm: fix symbol access
domenic Jun 1, 2015
5537c01
dgram: make send cb act as "error" event handler
chrisdickinson Jun 5, 2014
cb80141
dgram: make send cb act as "error" event handler
mcollina May 26, 2015
9f3946a
http_server: `prefinish` vs `finish`
indutny Apr 13, 2015
72b7f9d
buffer: fix case of one buffer passed to concat
thefourtheye Jun 10, 2015
093eae3
cluster: do not unconditionally set --debug-port
cjihrig Jun 11, 2015
271b706
buffer: fix usage of kMaxLength
trevnorris Jun 17, 2015
1baca79
buffer: minor cleanup from rebase
trevnorris Jun 17, 2015
d57350c
buffer: allow ArrayBuffer as Buffer argument
trevnorris Jun 17, 2015
d11d40f
deps: update v8 to 4.4.63.9
bnoordhuis Jun 19, 2015
84cef46
test: don't use arguments.callee
bnoordhuis Jun 19, 2015
b1570c5
test: remove two obsolete pummel tests
bnoordhuis Jun 19, 2015
2e53e03
buffer: rename internal/buffer_new.js to buffer.js
bnoordhuis Jun 19, 2015
31faa1b
node-gyp: make aware of nightly, next-nightly & rc
rvagg Jun 26, 2015
27cf131
node-gyp: download header tarball for compile
rvagg Jun 26, 2015
8f65dbb
Working on v3.0.0
rvagg Jun 30, 2015
bd51bc7
deps: upgrade v8 to 4.4.63.12
bnoordhuis Jul 1, 2015
35c7938
src: increment NODE_MODULE_VERSION to 45
rvagg Jul 2, 2015
df9cdd8
node: do not override `message`/`stack` of error
indutny Jul 5, 2015
fa5b871
http: use official IANA Status Codes
jomo Jul 11, 2015
b096278
src: introduce process.release object
rvagg Jan 18, 2015
6c97138
node-gyp: detect RC build with x.y.z-rc.n format
rvagg Jul 13, 2015
8d13222
buffer: fix not return on error
trevnorris Jul 22, 2015
be68537
build: first set of updates to enable PPC support
mhdawson Jul 7, 2015
606fdfa
build: add 'x86' option back in to configure
rvagg Jul 24, 2015
2f54e45
buffer: fix missing null/undefined check
trevnorris Jul 16, 2015
050ab42
node: remove redundant --use-old-buffer
rvagg Jul 30, 2015
c04c190
build: prepare Windows installer for i18n support
fhemberger Jul 25, 2015
fd8da09
readline: allow tabs in input
Trott May 21, 2015
d390a6f
http: fix agent.getName() and add tests
brendanashworth May 5, 2015
181c3bc
deps: update V8 to 4.4.63.26
targos Jul 27, 2015
fe22685
src: disable vector ICs on arm
targos Jul 30, 2015
40a9cae
doc: document repl persistent history changes
Fishrock123 Aug 4, 2015
8e5eae9
test: add tests for persistent repl history
Fishrock123 Aug 2, 2015
17c4108
repl: default persistence to ~/.node_repl_history
Fishrock123 Aug 4, 2015
f00e11b
repl: persist history in plain text
Fishrock123 Aug 3, 2015
966c977
2015-08-01 io.js v3.0.0 Release
rvagg Aug 1, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
readline: allow tabs in input
If tab completion is not being used, allow user to enter tab
characters.

PR-URL: #1761
Reviewed-By: Brendan Ashworth <[email protected]>
  • Loading branch information
Trott authored and rvagg committed Aug 4, 2015
commit fd8da09d687d7980a9d254c7e9c1a2dfcd286d9d
27 changes: 14 additions & 13 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ function Interface(input, output, completer, terminal) {
}
historySize = historySize || kHistorySize;

completer = completer || function() { return []; };

if (typeof completer !== 'function') {
if (completer && typeof completer !== 'function') {
throw new TypeError('Argument \'completer\' must be a function');
}

Expand All @@ -74,9 +72,11 @@ function Interface(input, output, completer, terminal) {
this.historySize = historySize;

// Check arity, 2 - for async, 1 for sync
this.completer = completer.length === 2 ? completer : function(v, callback) {
callback(null, completer(v));
};
if (typeof completer === 'function') {
this.completer = completer.length === 2 ? completer : function(v, cb) {
cb(null, completer(v));
};
}

this.setPrompt('> ');

Expand Down Expand Up @@ -346,9 +346,6 @@ Interface.prototype._normalWrite = function(b) {
};

Interface.prototype._insertString = function(c) {
//BUG: Problem when adding tabs with following content.
// Perhaps the bug is in _refreshLine(). Not sure.
// A hack would be to insert spaces instead of literal '\t'.
if (this.cursor < this.line.length) {
var beg = this.line.slice(0, this.cursor);
var end = this.line.slice(this.cursor, this.line.length);
Expand Down Expand Up @@ -841,10 +838,6 @@ Interface.prototype._ttyWrite = function(s, key) {
this._deleteRight();
break;

case 'tab': // tab completion
this._tabComplete();
break;

case 'left':
this._moveCursor(-1);
break;
Expand All @@ -869,6 +862,14 @@ Interface.prototype._ttyWrite = function(s, key) {
this._historyNext();
break;

case 'tab':
// If tab completion enabled, do that...
if (typeof this.completer === 'function') {
this._tabComplete();
break;
}
// falls through

default:
if (s instanceof Buffer)
s = s.toString('utf-8');
Expand Down
53 changes: 53 additions & 0 deletions test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,59 @@ function isWarned(emitter) {
assert.equal(callCount, expectedLines.length);
rli.close();

// \t when there is no completer function should behave like an ordinary
// character
fi = new FakeInput();
rli = new readline.Interface({ input: fi, output: fi, terminal: true });
called = false;
rli.on('line', function(line) {
assert.equal(line, '\t');
assert.strictEqual(called, false);
called = true;
});
fi.emit('data', '\t');
fi.emit('data', '\n');
assert.ok(called);
rli.close();

// \t does not become part of the input when there is a completer function
fi = new FakeInput();
var completer = function(line) {
return [[], line];
};
rli = new readline.Interface({
input: fi,
output: fi,
terminal: true,
completer: completer
});
called = false;
rli.on('line', function(line) {
assert.equal(line, 'foo');
assert.strictEqual(called, false);
called = true;
});
fi.emit('data', '\tfo\to\t');
fi.emit('data', '\n');
assert.ok(called);
rli.close();

// constructor throws if completer is not a function or undefined
fi = new FakeInput();
assert.throws(function() {
readline.createInterface({
input: fi,
completer: 'string is not valid'
});
}, function(err) {
if (err instanceof TypeError) {
if (/Argument \'completer\' must be a function/.test(err)) {
return true;
}
}
return false;
});

// sending a multi-byte utf8 char over multiple writes
var buf = Buffer('☮', 'utf8');
fi = new FakeInput();
Expand Down