-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Expand wildcards on tab #8593
Expand wildcards on tab #8593
Conversation
The handle_readline_command function is getting unwieldy, so factor it better to reduce its length. No functional change here.
When fish expands a string that starts with a tilde, like `~/stuff/*`, it first must resolve the tilde (e.g. to the user's home directory) before passing it to wildcard expansion. The wildcard expansion will produce full paths like `/home/user/stuff/file`. fish then "unexpands" the home directory back to a tilde. Previously this was only used during completions, but in the next commit we plan to use it for string expansions as well. Rationalize this behavior by adding an explicit flag to request it and explain some subtleties about completions.
Prior to this change, if you tab-completed a token with a wildcard (glob), we would invoke ordinary completions. Instead, expand the wildcard, replacing the wildcard with the result of expansions. If the wildcard fails to expand, flash the command line to signal an error and do not modify it. Example: > touch file(seq 4) > echo file*<tab> becomes: > echo file1 file2 file3 file4 whereas before the tab would have just added a space. Some things to note: 1. If the expansion would produce more than 256 items, we flash the command line and do nothing, since it would make the commandline overfull. 2. The wildcard token can be brought back through Undo (ctrl-Z). Fixes fish-shell#954.
97fafcb
to
68cc362
Compare
This is really powerful, but it disallows some scenarios,
(The glob is useful in case there are multiple directories with interesting files.) previously, we got a set of completions with entries like Maybe Sadly that's still not perfect, because sometimes preserving the glob is nice. Maybe there is a criteria to guess if the user wants expansion or not. Hopefully we can avoid a separate key binding. |
Maybe only expand Here are some scenarios (where
I think these are acceptable because filename completion rarely does much when there is a |
Prior to this change, if you tab-completed a token with a wildcard (glob), we would invoke ordinary completions. Instead, expand the wildcard, replacing the wildcard with the result of expansions. If the wildcard fails to expand, flash the command line to signal an error and do not modify it.
Example:
becomes:
whereas before the tab would have just added a space.
Some things to note:
Fixes #954.