This repository has been archived by the owner on Feb 21, 2023. It is now read-only.
Improved command completion when using '--'. #104
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have found that yak's completion breaks down in the following situation:
$ yak env -- [TAB]
I expect it to expand possible executables, but instead, it completes filenames (which is just a Zsh fallback shining though, i believe). A side-effect is that completions for commands i rely on also break:
This patch to the Zsh completion file does two main things:
Enable the
-S
flag to_arguments
as documented here: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Completion-Functions. Specifically, "-S
— Do not complete options after a ‘--’ appearing on the line, and ignore the ‘--’."Don't modify the
words
array ourselves; just call_normal
completion once we've got an environment specified in positional argument 1. Also, use 3 instead of 2 colons for'*:::command...
, which according to the docs means: With three colons before the message, the words special array and the CURRENT special parameter are modified to refer only to the normal arguments covered by this description.Finally, i've removed
--
as an explicit option, because-S
takes care of this in a nice built-in way.Completions now work as i expect them to, with or without the
--
between yak and the command i'm keen to run.