| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 88b02cb commit 797f7f8
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1144,7 +1144,7 @@ REPLServer.prototype.turnOffEditorMode = deprecate( | |||
| 1144 | 1144 | 'DEP0078'); | |
| 1145 | 1145 | ||
| 1146 | 1146 | const importRE = /\bimport\s*\(\s*['"`](([\w@./:-]+\/)?(?:[\w@./:-]*))(?![^'"`])$/; | |
| 1147 | - const requireRE = /\brequire\s*\(\s*['"`](([\w@./-]+\/)?(?:[\w@./-]*))(?![^'"`])$/; | ||
| 1147 | + const requireRE = /\brequire\s*\(\s*['"`](([\w@./:-]+\/)?(?:[\w@./:-]*))(?![^'"`])$/; | ||
| 1148 | 1148 | const fsAutoCompleteRE = /fs(?:\.promises)?\.\s*[a-z][a-zA-Z]+\(\s*["'](.*)/; | |
| 1149 | 1149 | const simpleExpressionRE = | |
| 1150 | 1150 | /(?:[a-zA-Z_$](?:\w|\$)*\??\.)*[a-zA-Z_$](?:\w|\$)*\??\.?$/; | |
@@ -1306,7 +1306,7 @@ function complete(line, callback) { | |||
| 1306 | 1306 | } | |
| 1307 | 1307 | ||
| 1308 | 1308 | if (!subdir) { | |
| 1309 | - ArrayPrototypePush(completionGroups, _builtinLibs); | ||
| 1309 | + ArrayPrototypePush(completionGroups, _builtinLibs, nodeSchemeBuiltinLibs); | ||
| 1310 | 1310 | } | |
| 1311 | 1311 | } else if (RegExpPrototypeTest(importRE, line) && | |
| 1312 | 1312 | this.allowBlockingCompletions) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,10 @@ const assert = require('assert'); | |||
| 31 | 31 | const path = require('path'); | |
| 32 | 32 | const fixtures = require('../common/fixtures'); | |
| 33 | 33 | const { builtinModules } = require('module'); | |
| 34 | + const publicModules = builtinModules.filter( | ||
| 35 | + (lib) => !lib.startsWith('_') && !lib.includes('/'), | ||
| 36 | + ); | ||
| 37 | + | ||
| 34 | 38 | const hasInspector = process.features.inspector; | |
| 35 | 39 | ||
| 36 | 40 | if (!common.isMainThread) | |
@@ -239,9 +243,9 @@ putIn.run(['.clear']); | |||
| 239 | 243 | ||
| 240 | 244 | testMe.complete('require(\'', common.mustCall(function(error, data) { | |
| 241 | 245 | assert.strictEqual(error, null); | |
| 242 | - builtinModules.forEach((lib) => { | ||
| 246 | + publicModules.forEach((lib) => { | ||
| 243 | 247 | assert( | |
| 244 | - data[0].includes(lib) || lib.startsWith('_') || lib.includes('/'), | ||
| 248 | + data[0].includes(lib) && data[0].includes(`node:${lib}`), | ||
| 245 | 249 | `${lib} not found` | |
| 246 | 250 | ); | |
| 247 | 251 | }); | |
@@ -258,11 +262,15 @@ testMe.complete("require\t( 'n", common.mustCall(function(error, data) { | |||
| 258 | 262 | assert.strictEqual(error, null); | |
| 259 | 263 | assert.strictEqual(data.length, 2); | |
| 260 | 264 | assert.strictEqual(data[1], 'n'); | |
| 265 | + // require(...) completions include `node:`-prefixed modules: | ||
| 266 | + publicModules.forEach((lib, index) => | ||
| 267 | + assert.strictEqual(data[0][index], `node:${lib}`)); | ||
| 268 | + assert.strictEqual(data[0][publicModules.length], ''); | ||
| 261 | 269 | // There is only one Node.js module that starts with n: | |
| 262 | - assert.strictEqual(data[0][0], 'net'); | ||
| 263 | - assert.strictEqual(data[0][1], ''); | ||
| 270 | + assert.strictEqual(data[0][publicModules.length + 1], 'net'); | ||
| 271 | + assert.strictEqual(data[0][publicModules.length + 2], ''); | ||
| 264 | 272 | // It's possible to pick up non-core modules too | |
| 265 | - data[0].slice(2).forEach((completion) => { | ||
| 273 | + data[0].slice(publicModules.length + 3).forEach((completion) => { | ||
| 266 | 274 | assert.match(completion, /^n/); | |
| 267 | 275 | }); | |
| 268 | 276 | })); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments