If I type the following code into the repl, and then press tab, a list of autocomplete suggestions appears for the require-able files in the current directory:
require('./
It would be nice if a similar thing would happen when calling methods like fs.readFileSync. Specifically, after typing the following code, I would want the REPL to autocomplete with all existing files in the current directory:
fs.readFileSync('./
This would be useful when using the REPL to process/view a file.
+1 on it. But there is a little difficulty to implement 100% of the feature.
Now we are using regular expression to match the code we want to autocomplete. It's easy to match something like fs.someMethod('./
But consider the following in REPL:
> var { readFileSync } = require('fs');
> readFileSync('./
Or even odder:
> var { readFileSync: foo } = require('fs');
> foo('./
We cannot use a single regular expression to match these. The most direct way is to match all the strings starting with ./ or ../.
But is it worth to do it?
@starkwang I'm fine with only solving this for people explicitly typing fs.someMethodSync( followed by a string literal of some sort (',", or `)
Just noting that auto-completion of file names in large directories will freeze the REPL until #15699 is resolved.
This should now be unblocked by #22020.
Most helpful comment
@starkwang I'm fine with only solving this for people explicitly typing
fs.someMethodSync(followed by a string literal of some sort (',", or `)