zsh: add guards to speed up completions#10434
Merged
MikeMcQuaid merged 1 commit intoHomebrew:masterfrom Jan 28, 2021
jonchang:guard-zsh-completions
Merged
zsh: add guards to speed up completions#10434MikeMcQuaid merged 1 commit intoHomebrew:masterfrom jonchang:guard-zsh-completions
MikeMcQuaid merged 1 commit intoHomebrew:masterfrom
jonchang:guard-zsh-completions
Conversation
If we type `brew install -<TAB>` we shouldn't try to shell out to Ruby to get a list of formulae for completions.
Contributor
|
Review period will end on 2021-01-28 at 03:15:54 UTC. |
Rylan12
approved these changes
Jan 27, 2021
Member
Rylan12
left a comment
There was a problem hiding this comment.
Looks good, thanks!
One suggestion to improve this even further
| } | ||
|
|
||
| __brew_formulae() { | ||
| [[ -prefix '-' ]] && return 0 |
Member
There was a problem hiding this comment.
Suggested change
| [[ -prefix '-' ]] && return 0 | |
| [[ -prefix '-' ]] && return 0 | |
| [[ -after '--cask' ]] && return 0 |
I've only briefly skimmed the docs and I haven't tested this, but will this work to ensure that formulae are not completed when --cask is passed?
And likewise, [[ -after '--formula' ]] && return 0 can be added to the __brew_*casks functions as well
Contributor
Author
There was a problem hiding this comment.
I looked into this briefly but I stumbled into some problems where if you wanted to specify multiple formulae to something like brew install it would stop doing completions. I'll dig into this later.
Contributor
|
Review period ended. |
BrewTestBot
approved these changes
Jan 28, 2021
Member
|
Thanks again @jonchang! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
If we type
brew install -<TAB>we shouldn't try to shell out to Ruby to get a list of formulae for completions, since formulae aren't allowed to start with a hyphen.This is especially important for commands that we can't or don't already cache, such as a list of outdated formulae or installed taps.
brew link --<TAB>before and after this pull request is a good example to showcase the speedup, or trybrew install --<TAB>after removing your zsh completions cache in~/.zcomp*.http://zsh.sourceforge.net/Doc/Release/Completion-Widgets.html#Completion-Condition-Codes
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith your changes locally?brew manlocally and committed any changes?