| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3348fe4 commit 5ee105c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,6 +119,9 @@ const { setImmediate } = require('timers'); | |||
| 119 | 119 | // Lazy-loaded. | |
| 120 | 120 | let processTopLevelAwait; | |
| 121 | 121 | ||
| 122 | + const globalBuiltins = | ||
| 123 | + new Set(vm.runInNewContext('Object.getOwnPropertyNames(globalThis)')); | ||
| 124 | + | ||
| 122 | 125 | const parentModule = module; | |
| 123 | 126 | const replMap = new WeakMap(); | |
| 124 | 127 | const domainSet = new WeakSet(); | |
@@ -907,8 +910,8 @@ REPLServer.prototype.createContext = function() { | |||
| 907 | 910 | context = vm.createContext(); | |
| 908 | 911 | }); | |
| 909 | 912 | for (const name of ObjectGetOwnPropertyNames(global)) { | |
| 910 | - // Only set properties on the context that do not exist as primordial. | ||
| 911 | - if (!(name in primordials)) { | ||
| 913 | + // Only set properties that do not already exist as a global builtin. | ||
| 914 | + if (!globalBuiltins.has(name)) { | ||
| 912 | 915 | ObjectDefineProperty(context, name, | |
| 913 | 916 | ObjectGetOwnPropertyDescriptor(global, name)); | |
| 914 | 917 | } | |
@@ -1257,8 +1260,14 @@ function complete(line, callback) { | |||
| 1257 | 1260 | completionGroups.push( | |
| 1258 | 1261 | filteredOwnPropertyNames.call(this, contextProto)); | |
| 1259 | 1262 | } | |
| 1260 | - completionGroups.push( | ||
| 1261 | - filteredOwnPropertyNames.call(this, this.context)); | ||
| 1263 | + const contextOwnNames = | ||
| 1264 | + filteredOwnPropertyNames.call(this, this.context); | ||
| 1265 | + if (!this.useGlobal) { | ||
| 1266 | + // When the context is not `global`, builtins are not own | ||
| 1267 | + // properties of it. | ||
| 1268 | + contextOwnNames.push(...globalBuiltins); | ||
| 1269 | + } | ||
| 1270 | + completionGroups.push(contextOwnNames); | ||
| 1262 | 1271 | if (filter !== '') addCommonWords(completionGroups); | |
| 1263 | 1272 | completionGroupsLoaded(); | |
| 1264 | 1273 | } else { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments