complete/zsh: improve --hyperlink-format completion #3102
+55
−1
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.
here's better completion for
--hyperlink-format
three known annoyances:
zsh doesn't perform brace expansion on single words, so users might be inclined to leave the variable braces unquoted, as in
--hyperlink-format=foo://{path}
. but i guess it generally assumes that it might and handles it at an earlier stage, which means our function doesn't even know the{
is there. this causes unexpected behaviour. there is also a bug (i assume zsh's rather than mine but idk) where it re-inserts the{
in a weird place, e.g.\{ho{st\}
zsh converts the the argument in
--opt=arg
style options to the\
-escaped (rather than quoted) form when completing it, which is not pleasant with the syntax used here and exacerbates the above issueif you have like
--hyperlink-format '{}
, press tab between the{}
, and then press}
after adding one of the matches, it won't swallow the extra}
off the top of my head idk if there's anything to be done about the first two. the last one can probably be fixed with
compadd -R
or sth. but tbh i got bored of the problemif these limitations bother you i can simplify it so it only tries to complete the aliases i guess
i also made it so helper functions aren't re-defined if they exist. this is a convention of many completion functions that allows end-users to more easily define their own helpers if they want them to behave differently. i just forgot to do it before