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