Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

repl: make tab completion work on non-objects

  • Loading branch information...
TooTallNate authored and bnoordhuis committed Feb 17, 2012
1 parent 30e462e commit a118f2172880d338101f80647437b8832ac1f768
Showing with 15 additions and 1 deletion.
  1. +6 −1 lib/repl.js
  2. +9 −0 test/simple/test-repl-tab-complete.js
@@ -523,8 +523,13 @@ REPLServer.prototype.complete = function(line, callback) {
}
// works for non-objects
try {
var p = Object.getPrototypeOf(obj);
var sentinel = 5;
var p;
if (typeof obj == 'object') {
p = Object.getPrototypeOf(obj);
} else {
p = obj.constructor ? obj.constructor.prototype : null;
}
while (p !== null) {
memberGroups.push(Object.getOwnPropertyNames(p));
p = Object.getPrototypeOf(p);
@@ -180,3 +180,12 @@ testMe.complete('inner.o', function(error, data) {
assert.deepEqual(data, doesNotBreak);
});

putIn.run(['.clear']);

// make sure tab completion works on non-Objects
putIn.run([
'var str = "test";'
]);
testMe.complete('str.len', function(error, data) {
assert.deepEqual(data, [ [ 'str.length' ], 'str.len' ]);
});

0 comments on commit a118f21

Please sign in to comment.
You can’t perform that action at this time.