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