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

Improve filename completer #203

Closed
wants to merge 5 commits into from
Closed

Improve filename completer #203

wants to merge 5 commits into from

Conversation

tkruse
Copy link
Contributor

@tkruse tkruse commented Aug 13, 2015

This fixes #90, and adds a lot of tests and some features to FileNameCompleter. The code is much more complex than before, and I would not trust it without the number of tests I added. It is possible that the code could be refactored somewhat, to save a few lines, in particular handling of closing hyphens with folders is ugly, as I though of it rather late. I will wait for feedback before spending more time on that.

The basic problem is when completing

mycommand "/path/to/fi

The completer needs to take into account plenty of things, like:

  • Does a candidate file with blank.txt exist that needs to be hyphenated 'file with blank.txt'?
  • Did the user already provide an opening hyphen, so a candidate should close them file.txt"?
  • Does the system expect further arguments and should add a blank after the filename?
  • Does the system want to complete only files, or only folders? (There is the option of supporting both, not supported by this PR)

Depending on the context, the completion should be different.
To merge, also consider this:

  • Should an variant exist of offer completion of both folders and files?
  • Should handling of initial hyphens be the default (breaks current behavior)?

I did not test the changes on other operating systems than Linux.

The small commits fixing minor stuff could be merged early, if you like.

- provide flag to complete folders only
- handles file and folders with blanks in name
- allow suppressing final blank
- allow completing folders instead of files
- allow handling existing leading hyphens correctly (use same hyphen for completion end)
@tkruse
Copy link
Contributor Author

tkruse commented Aug 13, 2015

Actually juggling with opening and closing hyphens that way is really ugly. I think I'd rather redo the whole PR with escaping blanks instead.

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

Successfully merging this pull request may close these issues.

FilenameCompletor finalizing blank suffix should be optional
1 participant