{Core} Disable aladdin recommendation in autocomplete mode#25145
Merged
{Core} Disable aladdin recommendation in autocomplete mode#25145
Conversation
6 tasks
Collaborator
|
Core |
kairu-ms
previously approved these changes
Jan 30, 2023
jiasli
reviewed
Jan 31, 2023
Comment on lines
+1365
to
+1368
| def is_autocomplete(): | ||
| """Detect if the command is running in autocomplete mode""" | ||
| from knack.completion import ARGCOMPLETE_ENV_NAME | ||
| return os.environ.get(ARGCOMPLETE_ENV_NAME) is not None |
Member
There was a problem hiding this comment.
I think we already have similar logic:
jiasli
reviewed
Jan 31, 2023
Comment on lines
+362
to
+363
| if is_autocomplete(): | ||
| return True |
Member
There was a problem hiding this comment.
This can be retrieved from self.cli_ctx.data['completer_active'].
jiasli
approved these changes
Feb 1, 2023
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
If the command is not complete, you will get recommendation.
For example, run
az accountyou getIn autocomplete mode, it's common that the command is not complete. The recommendation is useless and time-consuming.
So I disable it in autocomplete mode.
Testing Guide
time IFS=$'\013' _ARC_DEBUG=1 COMP_LINE='az account' COMP_POINT=11 COMP_TYPE="" _ARGCOMPLETE=1 _ARGCOMPLETE_SUPPRESS_SPACE=0 az 8>&1 1>&1 2>&1 9>&1takes 0.4s.After applying this PR, it only takes 0.2s.
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.