Node: Feature request: Autocomplete filenames for `fs` functions in repl

Created on 19 Dec 2017  路  5Comments  路  Source: nodejs/node

  • Version: 9.2.1
  • Platform: macOS Sierra
  • Subsystem: repl

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.

feature request repl

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 `)

All 5 comments

+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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcollina picture mcollina  路  3Comments

danialkhansari picture danialkhansari  路  3Comments

addaleax picture addaleax  路  3Comments

jmichae3 picture jmichae3  路  3Comments

willnwhite picture willnwhite  路  3Comments