GeezerVison is showing github.com — repl: disable blocking completions by default · nodejs/node@1ac07b2
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/repl.js +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -58,6 +58,7 @@ const { | 58 | 58 | Promise, | 59 | 59 | PromiseRace, | 60 | 60 | RegExp, | | 61 | + RegExpPrototypeTest, | 61 | 62 | Set, | 62 | 63 | StringPrototypeCharAt, | 63 | 64 | StringPrototypeIncludes, | @@ -267,6 +268,7 @@ function REPLServer(prompt, | 267 | 268 | configurable: true | 268 | 269 | }); | 269 | 270 |
| | 271 | + this.allowBlockingCompletions = !!options.allowBlockingCompletions; | 270 | 272 | this.useColors = !!options.useColors; | 271 | 273 | this._domain = options.domain || domain.create(); | 272 | 274 | this.useGlobal = !!useGlobal; | @@ -1186,7 +1188,8 @@ function complete(line, callback) { | 1186 | 1188 | if (completeOn.length) { | 1187 | 1189 | filter = completeOn; | 1188 | 1190 | } | 1189 | | - } else if (requireRE.test(line)) { | | 1191 | + } else if (RegExpPrototypeTest(requireRE, line) && | | 1192 | + this.allowBlockingCompletions) { | 1190 | 1193 | // require('...<Tab>') | 1191 | 1194 | const extensions = ObjectKeys(this.context.require.extensions); | 1192 | 1195 | const indexes = extensions.map((extension) => `index${extension}`); | @@ -1244,7 +1247,8 @@ function complete(line, callback) { | 1244 | 1247 | if (!subdir) { | 1245 | 1248 | completionGroups.push(_builtinLibs); | 1246 | 1249 | } | 1247 | | - } else if (fsAutoCompleteRE.test(line)) { | | 1250 | + } else if (RegExpPrototypeTest(fsAutoCompleteRE, line) && | | 1251 | + this.allowBlockingCompletions) { | 1248 | 1252 | [completionGroups, completeOn] = completeFSFunctions(line); | 1249 | 1253 | // Handle variable member lookup. | 1250 | 1254 | // We support simple chained expressions like the following (no function | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-repl-tab-complete.js +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,7 +51,12 @@ function getNoResultsFunction() { | 51 | 51 |
| 52 | 52 | const works = [['inner.one'], 'inner.o']; | 53 | 53 | const putIn = new ArrayStream(); | 54 | | -const testMe = repl.start('', putIn); | | 54 | +const testMe = repl.start({ | | 55 | + prompt: '', | | 56 | + input: putIn, | | 57 | + output: process.stdout, | | 58 | + allowBlockingCompletions: true | | 59 | +}); | 55 | 60 |
| 56 | 61 | // Some errors are passed to the domain, but do not callback | 57 | 62 | testMe._domain.on('error', assert.ifError); | |
|