|
43 | 43 | 'use strict'; |
44 | 44 |
|
45 | 45 | const { |
46 | | - ArrayIsArray, |
47 | 46 | MathMax, |
48 | 47 | NumberIsNaN, |
49 | 48 | ObjectAssign, |
@@ -1277,40 +1276,23 @@ function complete(line, callback) { |
1277 | 1276 | // Resolve expr and get its completions. |
1278 | 1277 | const memberGroups = []; |
1279 | 1278 | if (!expr) { |
1280 | | - // If context is instance of vm.ScriptContext |
1281 | 1279 | // Get global vars synchronously |
1282 | | - if (this.useGlobal || vm.isContext(this.context)) { |
1283 | | - completionGroups.push(getGlobalLexicalScopeNames(this[kContextId])); |
1284 | | - let contextProto = this.context; |
1285 | | - while (contextProto = ObjectGetPrototypeOf(contextProto)) { |
1286 | | - completionGroups.push( |
1287 | | - filteredOwnPropertyNames.call(this, contextProto)); |
1288 | | - } |
1289 | | - const contextOwnNames = |
1290 | | - filteredOwnPropertyNames.call(this, this.context); |
1291 | | - if (!this.useGlobal) { |
1292 | | - // When the context is not `global`, builtins are not own |
1293 | | - // properties of it. |
1294 | | - contextOwnNames.push(...globalBuiltins); |
1295 | | - } |
1296 | | - completionGroups.push(contextOwnNames); |
1297 | | - if (filter !== '') addCommonWords(completionGroups); |
1298 | | - completionGroupsLoaded(); |
1299 | | - } else { |
1300 | | - this.eval('.scope', this.context, 'repl', function ev(err, globals) { |
1301 | | - if (err || !ArrayIsArray(globals)) { |
1302 | | - if (filter !== '') addCommonWords(completionGroups); |
1303 | | - } else if (ArrayIsArray(globals[0])) { |
1304 | | - // Add grouped globals |
1305 | | - for (let n = 0; n < globals.length; n++) |
1306 | | - completionGroups.push(globals[n]); |
1307 | | - } else { |
1308 | | - completionGroups.push(globals); |
1309 | | - if (filter !== '') addCommonWords(completionGroups); |
1310 | | - } |
1311 | | - completionGroupsLoaded(); |
1312 | | - }); |
| 1280 | + completionGroups.push(getGlobalLexicalScopeNames(this[kContextId])); |
| 1281 | + let contextProto = this.context; |
| 1282 | + while (contextProto = ObjectGetPrototypeOf(contextProto)) { |
| 1283 | + completionGroups.push( |
| 1284 | + filteredOwnPropertyNames.call(this, contextProto)); |
| 1285 | + } |
| 1286 | + const contextOwnNames = |
| 1287 | + filteredOwnPropertyNames.call(this, this.context); |
| 1288 | + if (!this.useGlobal) { |
| 1289 | + // When the context is not `global`, builtins are not own |
| 1290 | + // properties of it. |
| 1291 | + contextOwnNames.push(...globalBuiltins); |
1313 | 1292 | } |
| 1293 | + completionGroups.push(contextOwnNames); |
| 1294 | + if (filter !== '') addCommonWords(completionGroups); |
| 1295 | + completionGroupsLoaded(); |
1314 | 1296 | } else { |
1315 | 1297 | const evalExpr = `try { ${expr} } catch {}`; |
1316 | 1298 | this.eval(evalExpr, this.context, 'repl', (e, obj) => { |
|
0 commit comments