Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vorpal version 1 autocomplete problem #285

Open
ORESoftware opened this issue Oct 15, 2017 · 4 comments · May be fixed by jircs/vorpaljircs9#1 or jircs/vorpaljircs9#2
Open

Vorpal version 1 autocomplete problem #285

ORESoftware opened this issue Oct 15, 2017 · 4 comments · May be fixed by jircs/vorpaljircs9#1 or jircs/vorpaljircs9#2

Comments

@ORESoftware
Copy link
Contributor

ORESoftware commented Oct 15, 2017

I created this video demonstrating the problem

https://www.useloom.com/share/40a9509bf03248d586d0357894f0edf4

I would like to use tab completion to access a directory

something like this:

node test/src/dev/node/foo.test.js

but using Vorpals autocomplete functionality does not make tab completing through a filesystem easy at all because Vorpal adds an extra character after the user hits tab. See the video.

My code to do the autocompletion looks like this:

  vorpal.command('run [file]')
  .description('run a single test script')
  .autocomplete({
    data: function (input: string, cb: Function) {

      const basename = path.basename(input);
      const dir = path.dirname(path.resolve(process.cwd() + `/${input}`));

      fs.readdir(dir, function (err, items) {
        if (err) {
          return cb(null);
        }
        const matches = items.filter(function (item) {
          return String(item).match(basename);
        });

        return cb(matches);

      });

    }
  })
@ORESoftware
Copy link
Contributor Author

ORESoftware commented Oct 23, 2017

any word on this bird?

I think it might be this line

var space = (String(strip(matches[0])).slice(strip(matches[0]).length - 1) === '/') ? '' : ' ';

@ORESoftware
Copy link
Contributor Author

this one is important to me, if someone can help me with it -
@dthree @milesj

@ORESoftware ORESoftware mentioned this issue Nov 6, 2017
11 tasks
@dthree
Copy link
Owner

dthree commented Nov 7, 2017

Hi @ORESoftware. Thanks for the video. Yes, adding a space is intended functionality, and file system navigation is the one place I've observed this to come up as an issue.

Perhaps we can add a flag on the tabbed autocompletion command? In this way, you can make the space omission command-specific.

By the way, there's already a file-system autocompletion library:

https://github.com/vorpaljs/vorpal-autocomplete-fs

@ORESoftware
Copy link
Contributor Author

oh nice, let me try that fs autocompletion lib, if it doesn't work I will report back very soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants