added 3 commits
December 28, 2021 21:37The 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.