mirror of https://github.com/nodejs/node.git
repl: make tab completion read up the prototype of "global"
For example, there's a global "toString()" function, so the REPL's tab completion should pick that up.pull/24503/head
parent
98b4596a46
commit
f405daa922
|
@ -535,6 +535,10 @@ REPLServer.prototype.complete = function(line, callback) {
|
|||
if (this.useGlobal ||
|
||||
this.context.constructor &&
|
||||
this.context.constructor.name === 'Context') {
|
||||
var contextProto = this.context;
|
||||
while (contextProto = Object.getPrototypeOf(contextProto)) {
|
||||
completionGroups.push(Object.getOwnPropertyNames(contextProto));
|
||||
}
|
||||
completionGroups.push(Object.getOwnPropertyNames(this.context));
|
||||
addStandardGlobals();
|
||||
completionGroupsLoaded();
|
||||
|
|
|
@ -202,3 +202,9 @@ testMe.complete(' ', function(error, data) {
|
|||
assert.deepEqual(data, [[],undefined]);
|
||||
clearTimeout(spaceTimeout);
|
||||
});
|
||||
|
||||
// tab completion should pick up the global "toString" object, and
|
||||
// any other properties up the "global" object's prototype chain
|
||||
testMe.complete('toSt', function(error, data) {
|
||||
assert.deepEqual(data, [['toString'], 'toSt']);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue