repl: fix tab completion for a non-global context
Use vm.isContext() to properly identify contexts. PR-URL: https://github.com/joyent/node/pull/25382 PR-URL: https://github.com/nodejs/io.js/pull/2052 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
c370bd3aea
commit
d735b2c6ef
@ -611,9 +611,7 @@ REPLServer.prototype.complete = function(line, callback) {
|
||||
if (!expr) {
|
||||
// If context is instance of vm.ScriptContext
|
||||
// Get global vars synchronously
|
||||
if (this.useGlobal ||
|
||||
this.context.constructor &&
|
||||
this.context.constructor.name === 'Context') {
|
||||
if (this.useGlobal || vm.isContext(this.context)) {
|
||||
var contextProto = this.context;
|
||||
while (contextProto = Object.getPrototypeOf(contextProto)) {
|
||||
completionGroups.push(Object.getOwnPropertyNames(contextProto));
|
||||
|
@ -206,3 +206,13 @@ testMe.complete('require(\'n', function(error, data) {
|
||||
assert.strictEqual(error, null);
|
||||
assert.deepEqual(data, [['net'], 'n']);
|
||||
});
|
||||
|
||||
// Make sure tab completion works on context properties
|
||||
putIn.run(['.clear']);
|
||||
|
||||
putIn.run([
|
||||
'var custom = "test";'
|
||||
]);
|
||||
testMe.complete('cus', function(error, data) {
|
||||
assert.deepEqual(data, [['custom'], 'cus']);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user